1

I am trying to install pip on my company's windows machine, but I don't have admin permission, so I have to install it else where.

When I set the path in prefix:

python setup.py install --prefix="C:\Developers\lib"

There goes the error:

running install
Checking .pth file support in C:\Developers\pythonLib\Lib\site-packages\
C:\Program Files (x86)\Python27\pythonw.exe -E -c pass
TEST FAILED: C:\Developers\pythonLib\Lib\site-packages\ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
    C:\Developers\lib\Lib\site-packages\
and your PYTHONPATH environment variable currently contains:

''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.

Do you have any suggestions? Thanks!

UPDATE:

I don't have the permission to edit environment variables, so I thought I cannot edit the Pythonpath. but I noticed that I can use

set PYTHONPATH=C:\Developers\pythonLib\Lib\site-packages

, and then

python setup.py install --prefix="C:Developers\pythonLib"

to solve the issue.

2
  • 2
    You mean suggestions beyond the three in the error message? Commented Jun 29, 2015 at 18:20
  • @jonrsharpe I can install python sharepoint module in the same way, but pip goes with the error... do you know why? Commented Jun 29, 2015 at 18:24

2 Answers 2

1

Add your directory to the PYTHONPATH environment variable and you'll be able to install packages there using python setup.py install --prefix=dir or pip install package_name -t dir.

But I would recommend to use virtualenv instead.

Sign up to request clarification or add additional context in comments.

3 Comments

I don't have admin permission to edit environment variable... and I tried to install virtualenv, comes with the same error...
@Robert if you don't have admin rights, you cannot set system variables, but you should be able to change user variables.
@Robert now I've noticed the update. That's exactly what I meant. If you want to have this permanent, you can edit the variable under Control panel -> System -> Advanced System Settings -> Advanced -> Environment variables -> User variables for %USERNAME% or using setx command instead of set.
0

The simplest way to install a python package into a specific folder is to use the -t, --target <dir> command. This Install packages into <dir>. By default this will not replace existing files/folders in <dir>.

Command: pip install --target <path directory> <package name>

Ex: pip install --target C:\test requests

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.