pip install customized include path

2019-03-18 08:51发布

I'm trying to install a library pyleargist. It requires another lib libfftw3 to be manually installed which I've installed. Since I don't have the root privilege, I have to install libfftw3 under my home directory: ~/usr/include and ~/usr/lib. Then I follow this post: https://superuser.com/questions/242190/how-to-install-matplotlib-on-os-x, added:

export LDFLAGS="-L~/usr/lib"
export CFLAGS="-I~/usr/include 

So that pip knows it have to consult /usr to get the include (.h files) and lib (.a, *.so files). However, while running pip install --user pyleargist, it complains about:

gcc-4.4.real: src/leargist.c: No such file or directory
gcc-4.4.real: no input files
error: command 'gcc' failed with exit status 1

I guess what happened is that the path is incorrect so that it can't find the *.c files (I think pip should have downloaded the file somewhere but not sure where it is).

So my questions are the following: 1) in this particular case, how can I install pyleargist with include and lib path under ~/usr? 2) more generally, how can one provide additional path for pip so that it knows where to get the additional include files or libs if not found in the default path?

p.s I am on an ubuntu machine without sudo privilege.

ref:
https://pypi.python.org/pypi/pyleargist/1.0.1
http://www.fftw.org/

3条回答
Juvenile、少年°
2楼-- · 2019-03-18 09:23

if you dont have root you can get a virtual enviroment no root is needed to get one and your path will be in home

curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.10.1.tar.gz
tar xvfz virtualenv-1.10.1.tar.gz
cd virtualenv-1.10.1.tar.gz
python virtualenv.py myVE

then your path is set in your home:

cd myVE/bin
./python

>>> import sys
>>> sys.path
['', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python33.zip', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/plat-linux', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/lib-dynload', '/usr/lib64/python3.3', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-linux', '/home/foobar/temp/virtualenv-1.10.1/myVE/lib/python3.3/site-packages']
>>> 
查看更多
可以哭但决不认输i
3楼-- · 2019-03-18 09:33

This was a helpful thread. Just to add on to this, you can also use pip without root if you pass the --user flag at the end:

pip install --global-option="-I/home/users/abc/include/" mpi4py --user

For example, if you're using python-v2.7, the above command installs the python package to /home/username/.local/lib/python2.7/site-packages

查看更多
乱世女痞
4楼-- · 2019-03-18 09:35

pip has a --global-option flag

You can use it to pass additional flags to build_ext.

For instance, to add a -I flag:

pip install --global-option=build_ext --global-option="-I/home/users/abc/include/" pyOpenSSL
查看更多
登录 后发表回答