6

I'm trying to install couple of modules via pip into custom directory using flag --target.

e.g.:

pip3 install --target /custom/module/location /path/to/package1

Everything works just fine. By adding /custom/module/location to PYTHONPATH I can use my package1.

But when I try to install package2 which requires package1 (located in /custom/module/location) pip throws:

Could not find a version that satisfies the requirement ...
No matching distribution found ...

Basically:

PYTHONPATH=/custom/module/location
pip3 install --target /custom/module/location /path/to/package1
pip3 install --target /custom/module/location /path/to/package2

does not work, but

pip3 install --user /path/to/package1
pip3 install --user /path/to/package2

works just fine. Is there any way of telling pip to look into custom location /custom/module/location other than PYTHONPATH?

btw when using first method, pip3 list can see the package1

2 Answers 2

5

I think target switch will be used like this:

pip install --target=/home/path/of/directory package_name

You need to add /home/path/of/directory to PYTHONPATH to actually use them from that location.

You can upgrade pip by:-

pip install -U pip
Sign up to request clarification or add additional context in comments.

2 Comments

I'm installing local packages, which is why pip install argument is poiting to a directory containing setup.py
no virtualenv on the server nor root access, thats why I'm installing modules to custom folder. setup.py installation is working just fine without virtualenv (for example package1 and other pakcages are working fine)
2

Solved it by using raw setuptools. First add a path to PYTHONPATH and then install local packages.

EXTRAPATH=/home/path/of/directory/lib/python3.5/site-packages
export PYTHONPATH=$PYTHONPATH:$EXTRAPATH
cd /path/to/package1 && python setup.py --prefix=/home/path/of/directory
cd /path/to/package2 && python setup.py --prefix=/home/path/of/directory

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.