Python Pip Specify a Library Directory and an Include Directory

Install a Python package into a different directory using pip?

Use:

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

You might also want to use --ignore-installed to force all dependencies to be reinstalled using this new prefix. You can use --install-option to multiple times to add any of the options you can use with python setup.py install (--prefix is probably what you want, but there are a bunch more options you could use).

install python package at current directory

You can use the target (t) flag of pip install to specify a target location for installation.

In use:

pip install -r requirements.txt -t /path/to/directory

to the current directory:

pip install -r requirements.txt -t .

How pip knows what path to include when compiles?

Solved with manual pointing to include path and library path:

pip install --global-option=build_ext 
--global-option="-IC:\Program Files\MySQL\MySQL Connector C 6.0.2\include"
--global-option="-LC:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt" mysql-python==1.2.5

But it is still interesting why pip wants another version.

How do I add all include .h files in python directory

pyhook is a Python package with binary dependencies.

When running pip install pyhook3 you download the source and ask your computer to build it so it can be installed. It thus requires a compiler and a set of header files that are apparently missing for you.

A workaround may be to download manually a compiled version of this package and install it.

You can find on this page a set of binary wheel for pyhook (not pyhook3) for python3 (32 or 64 bit). Once you have downloaded the correct .whl, you can install it with pip install the_filename_you_have_downloaded.whl

pip install local package to target directory

For one-time testing of a new package, installing directly from the local filesystem seems to be the best bet:

$ cd /my/sample/application
$ pip install -t lib /my/local/package

This install won't stay in sync as I make further changes to the local package (as it would if I were to use pip install --editable), but I can live without that for this use case.

I couldn't get @pbaranay's answer to work because of the way pip install -e uses "egg-info" files that apparently are not understood/traversed by GAE's dev_appserver.py script. The suggestion to create a virtualenv and symlink it to lib (rather than installing packages directly to lib with -t) is a good one, though.



Related Topics



Leave a reply



Submit