Where is site packages on linux




















Viewed 7k times. My chain of commands was: install WSL - Ubuntu Improve this question. Evgeny Evgeny 1 1 silver badge 6 6 bronze badges. Any comment accompanying a downvote will be highly appreciated — Evgeny. First of all, never use sudo pip install. By that, you save yourself a lot of future errors. Use pip install --user instead.

Do it right now: got through pip3 list output, try to find packages you already installed plus their dependencies , uninstall and reinstall them as user. By doing that, you will immediately notice the commands to become available because of the PATH changes you made.

If you, however, like to live on the edge and insist on sudo pip install ing, adjust the PATH correctly: check out the output of pip3 show cheat grep Location , two segments up and descend into bin and add that directory to PATH. Do you care to put these comments as an answer, so that I can accept it? As a best practice, you should always install Python and the packages you need into a separate virtual environment for each project.

The Pip Package Manager can be used to list both globally and locally installed Python packages. The Pipenv, Anaconda Navigator and Conda package managers can also be used to list locally installed packages in their respective environments. Pip installs packages globally by default. To list globally installed packages and their version use:.

To list a single globally installed package and its version , use the following command depending on your OS:. Although pip installs packages globally by default, packages that have been installed locally with the —user option can also be listed using the same —user option, as follows:. This naturally raises the question - how does Python know where to find packages when you call import?

This post applies specifically to Python 2. In this post I first describe how Python finds packages, and then I'll finish with the discovery I made regarding the default Python that ships with Ubuntu and how it differs from vanilla Python in how it finds packages. 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.

In the future, more directories will be added to handle Python scripts, documentation, binary executables, and whatever else is needed to handle the job of installing Python modules and applications. They are always the same under Windows, and very often the same under Unix and macOS.

You can find out what your Python installation uses for prefix and exec-prefix by running Python in interactive mode and typing a few simple commands. Under Unix, just type python at the shell prompt. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python statements shown below, and get the output as shown, to find out my prefix and exec-prefix :. A few other placeholders are used in this document: X.

Y stands for the version of Python, for example 3. Dots and capitalization are important in the paths; for example, a value that uses python3. If you want to customize your installation directories more heavily, see section Custom Installation on custom installations.

Often, it is necessary or desirable to install modules to a location other than the standard location for third-party Python modules. For example, on a Unix system you might not have permission to write to the standard third-party module directory. Or you might wish to try out a module before making it a standard part of your local Python installation.

This is especially true when upgrading a distribution already present: you want to make sure your existing base of scripts still works with the new version before actually upgrading.

The Distutils install command is designed to make installing module distributions to an alternate location simple and painless. The basic idea is that you supply a base directory for the installation, and the install command picks a set of directories called an installation scheme under this base directory in which to install files. The details differ across platforms, so read whichever of the following sections applies to you. It is enabled with a simple option:.

Files will be installed into subdirectories of site. This scheme installs pure Python modules and extension modules in the same location also known as site. The advantage of using this scheme compared to the other ones described below is that the user site-packages directory is under normal conditions always included in sys. This scheme can be used by anyone, regardless of the operating system they are installing for. The --home option defines the installation base directory.

Files are installed to the following directories under the installation base as follows:. However, there are at least two known cases where the prefix scheme will be useful. This can be done with. This could be done with. In either case, the --prefix option defines the installation base, and the --exec-prefix option defines the platform-specific installation base, which is used for platform-specific files.

Currently, this just means non-pure module distributions, but could be expanded to C libraries, binary executables, etc. If --exec-prefix is not supplied, it defaults to --prefix.

Files are installed as follows:. There is no requirement that --prefix or --exec-prefix actually point to an alternate Python installation; if the directories listed above do not already exist, they are created at installation time. Incidentally, the real reason the prefix scheme is important is simply that a standard Unix installation uses the prefix scheme, but with --prefix and --exec-prefix supplied by Python itself as sys.

Note that installing extensions to an alternate Python installation has no effect on how those extensions are built: in particular, the Python header files Python.

It is your responsibility to ensure that the interpreter used to run extensions installed in this way is compatible with the interpreter used to build them. The best way to do this is to ensure that the two interpreters are the same version of Python possibly different builds, or possibly copies of the same build. The installation base is defined by the --prefix option; the --exec-prefix option is not supported under Windows, which means that pure Python modules and extension modules are installed into the same location.

You might want to tweak just one or two directories while keeping everything under the same base directory, or you might want to completely redefine the installation scheme. To create a custom installation scheme, you start with one of the alternate schemes and override some of the installation directories used for the various types of files, using these options:. These override options can be relative, absolute, or explicitly defined in terms of one of the installation base directories.

As you might expect, you can override this directory with the --install-scripts option; in this case, it makes most sense to supply a relative path, which will be interpreted relative to the installation base directory your home directory, in this case :.



0コメント

  • 1000 / 1000