Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip --user installs package to Default user directory on Windows 10

Tags:

I have a problem on Windows 10 where both Python 2.6 and 2.7 are installed.

python -m pip install myPack --no-index --find-links=. --user

When running this command with user AutoUser it installs myPack to Default user directory C:\Users\Default\Python\Python27\site-packages or C:\Users\Default\Appdata\Roaming\Python\site-packages instead C:\Users\Autouser\Appdata\Roaming\Python\site-packages

  • Installation is automatic soon after windows logon, but I can see in logs that "query user" returns a row with AutoUser (before calling pip).
  • Other OS don't have this problem.
  • Reproduction is unstable on Windows 10: maybe 1 time of 100.
  • Truth that python 2.6 is also installed on these machines, but I'm not sure it is meaningful: 2.6 goes later than 2.7 in Path system variable. Here they write it could be a problem, but pip doesn't confuse python versions, it confuses users' directories.

Path:

C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts\;C:\Python26\;C:\Python26\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;

Python version:

python --version
Python 2.7.13

Pip version:

python -m pip --version
Pip version: pip 9.0.1 from C:\Python27\lib\site-packages (python 2.7) 
like image 486
flam3 Avatar asked Sep 12 '18 08:09

flam3


People also ask

Where does pip user install packages?

Here you can see that the location field says the package is installed at /usr/local/lib/python3. 8/site-packages. The location obviously depends on your system and Python version.

Where does pip -- user install Windows?

pip when used with virtualenv will generally install packages in the path <virtualenv_name>/lib/<python_ver>/site-packages .

Does pip install packages for all users?

Passing the --user option to python -m pip install will install a package just for the current user, rather than for all users of the system.


1 Answers

You can try setting the install target with the --target option like so:

pip install --target=C:\Users\Autouser\Appdata\Roaming\Python\site-packages package_name

If that doesn't work, another option is to try using --install-option like this:

pip install --install-option="--prefix=$PREFIX_PATH" package_name

Finally, if all else fails, here's one more way to do it:

PYTHONUSERBASE=/path/to/install/to pip install --user

You can specify which python version to install the package for by using python2.x -m pip install ...

Hopefully one of these helps you! :)

like image 191
DeltaMarine101 Avatar answered Oct 23 '22 11:10

DeltaMarine101