kylemart
kylemart

Reputation: 1276

Pip3 didn't install a user-scoped package to ~/.local/bin

I recently installed pipenv using the following command: pip3 install --user pipenv. (It's also worth mentioning that I'm following Python's official guide here.) Most online resources seem to indicate that the default installation directory for user-scoped packages is at ~/.local/bin. However, it would seem that my installation of pipenv resides in ~/Library/Python/3.6/bin. I'm concerned that keeping the installation in a version specific directory (i.e. Python 3.6) could lead to problems down the road. What happened? Should I be worried?

Upvotes: 0

Views: 177

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1122342

This is entirely correct behaviour, and not something that you need to worry about.

Python packages with native compiled extensions are tied to the specific Python version into which it is installed and should not be shared. Because you can't detect a-priori what package will contain native extensions, all Python packages are installed in a version-specific location.

The --user switch installs in the User Scheme location:

With Python 2.6 came the "user scheme" for installation, which means that all Python distributions support an alternative install location that is specific to a user. The default location for each OS is explained in the python documentation for the site.USER_BASE variable. This mode of installation can be turned on by specifying the --user option to pip install.

You can always list your USER_BASE location by running:

python3 -m site

(using the same Python binary as tied to your pip command).

The Python module search path automatically includes the user location, and because that location is Python version (major.minor) specific, won't interfere with other Python versions.

~/Library/Python/3.6/ is the Mac OS X specific path used when you have a framework build. You can override the path by setting the PYTHONUSERBASE environment variable.

Upvotes: 2

Related Questions