22

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/

Community
  • 1
  • 1
clwen
  • 20,004
  • 31
  • 77
  • 94
  • 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? – drevicko Oct 21 '13 at 05: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. – clwen Oct 24 '13 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? – drevicko Oct 25 '13 at 00:29
  • Possible duplicate of [python pip specify a library directory and an include directory](https://stackoverflow.com/questions/18783390/python-pip-specify-a-library-directory-and-an-include-directory) – mattm Mar 12 '19 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! – pbnelson Sep 20 '22 at 02:06

3 Answers3

32

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
hahakubile
  • 6,978
  • 4
  • 28
  • 18
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

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
0

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']
>>> 
Foo Bar User
  • 2,401
  • 3
  • 20
  • 26