Where is site packages python




















This toggle is enabled by default for Conda environments. Click the button on the package toolbar. To specify a custom repository, including devpi or PyPi , click Manage Repositories. In the Available Packages dialog, click to reload the list of the packages.

Type the name of the package to install in the Search field. The list shrinks to show the matching packages only. Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. Global site-packages " dist-packages " directories are listed in sys.

For a more concise list run getsitepackages from the site module in Python code:. Note: With virtualenvs getsitepackages is not available , sys. In Python 3, you may use the sysconfig module instead:. The per user site-packages directory PEP is where Python installs your local packages:. If this points to a non-existing directory check the exit status of Python and see python -m site --help for explanations.

Hint: Running pip list --user or pip freeze --user gives you a list of all installed per user site-packages. Source: an very old version of "How to Install Django" documentation though this is useful to more than just Django installation.

This folder only contains packages your operating system has automatically installed for programs to run. The second folder is probably the more useful one if the use case is related to installation or reading source code. If you do not use Ubuntu, you are probably safe copy-pasting the first code box into the terminal.

A modern stdlib way is using sysconfig module, available in version 2. Unlike the current accepted answer, this method still works regardless of whether or not you have a virtual environment active.

Note : sysconfig source is not to be confused with the distutils. Python currently uses eight paths docs :. In most cases, users finding this question would be interested in the 'purelib' path in some cases , you might be interested in 'platlib' too.

The purelib path is where ordinary Python packages will be installed by tools like pip. The function sysconfig. A shell script is also available to display these details, which you can invoke by executing sysconfig as a module:.

Let's say you have installed the package 'django'. It will show you, all the functions and attributes with that module. Type in the python interpreter -. That said, what's the context? The native system packages installed with python installation in Debian based systems can be found at :. All the answers or: the same answer repeated over and over are inadequate.

What you want to do is this:. The final line shows you the installation dir. Works on Ubuntu, whereas the above ones don't. Have fun. Note: original code has many swearwords in it. A side-note: The proposed solution distutils. It will only return the main site-packages directory. Alas, I have no better solution either. Python doesn't seem to keep track of site-packages directories, just the packages within them.

This works for me. It will get you both dist-packages and site-packages folders. If the folder is not on Python's path, it won't be doing you much good anyway.

As the docs explain, sys. You can read more about sys. The site module is automatically imported when you start Python, you can read more about how it manipulates your sys. You can manipulate sys. For example:. However, the Python docs state that:. Its impact should thus be kept to a minimum. The primary intended purpose of executable lines is to make the corresponding module s importable load 3rd-party import hooks, adjust PATH etc.

Limiting a code chunk to a single line is a deliberate measure to discourage putting anything more complex here. For example, suppose sys. The Python X. Assume foo. Then the following version-specific directories are added to sys. After these path manipulations, an attempt is made to import a module named sitecustomize , which can perform arbitrary site-specific customizations.

It is typically created by a system administrator in the site-packages directory. If Python is started without output streams available, as with pythonw. Any other exception causes a silent and perhaps mysterious failure of the process.

This file is intended to be created in the user site-packages directory see below , which is part of sys. Note that for some non-Unix systems, sys. On systems that support readline , this module will also import and configure the rlcompleter module, if Python is started in interactive mode and without the -S option.



0コメント

  • 1000 / 1000