25

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/

5
  • how did you go? Do you have all the missing dependencies in ~/usr/..? Are the versions you've got there compatible with dependencies installed on the system? Commented Oct 21, 2013 at 5:41
  • @drevicko Yes. There is only on dependency and I put it in ~/usr/. They are compatible. I know it because I can install it on other machines where I have sudo privilege. Commented Oct 24, 2013 at 18:23
  • What's the gcc command that generated the error? Also the location of leargist.c and if it exists somewhere in your ~/usr/ or elsewhere? Commented Oct 25, 2013 at 0:29
  • Possible duplicate of python pip specify a library directory and an include directory Commented Mar 12, 2019 at 21:49
  • 1
    Ironically, on my mac arm trying to install pyopencl I had the same error regarding a missing Python.h file. But in my case the problem was fixed by the export CFLAGS=-I/whatever approach. The --global-option="-I/whatever" approach failed miserably. So thanks for the question! Commented Sep 20, 2022 at 2:06

3 Answers 3

36

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
Sign up to request clarification or add additional context in comments.

1 Comment

For those coming to this thread in 2024 and on, --global-option and --build-option are now deprecated and replaced by --config-settings. An alternative option is to use the export CPPFLAGS environment variable. export CPPFLAGS=-I//home/usr/abc/include; pip install pyOpenSSL
1

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']
>>> 

Comments

1

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

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.