0

I'm trying to install PyCaffe for Python 3.5.3 on AWS EC2 with Ubuntu 14.04 without Anaconda, following the installation instructions.

I successfully compiled it on the same machine for Python 2.7 but when compiling for version 3.5 I get the following error:

ubuntu@ip-172-31-3-227:~/caffe$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
 #include <Python.h>  // NOLINT(build/include_alpha)

I saw this post and performed:

sudo apt-get install python3-dev

I found this, so I performed the equivalent command for Python 3.5:

for req in $(cat requirements.txt); do sudo pip3.5 install $req; done

All installations worked but it didn't fix the problem.

I many other posts on similar problems but not this exact problem (so if you find something please check that it's really the same situation before rushing to say I didn't look well enough).

P.S.

I also saw this post but I don't understand which directories to add to the path.

traveh
  • 2,700
  • 3
  • 27
  • 44

1 Answers1

1

When you do a pip install package,when pip finds new version,it uninstall the current one(dateutil in your case) when the package was installed using certain permission,pip needs the same permission to uninstall/upgrade it.

A quick fix would be to change this

`for req in $(cat requirements.txt); do pip3.5 install $req; done` to

for req in $(cat requirements.txt); do sudo pip3.5 install $req; done

It seems you dont have permission to access /usr/local/lib/python3.5/ folder as user,the packages that goes in /usr/local are required by the system but only available to you and only you on the system, i assume since only only they are restricted to you and pip want to access assuming that no restriction is there,then it get permission denied ,so you might consider doing

for req in $(cat requirements.txt); do  pip3.5 --user yourusername install $req; done

the alternative is to remove any restriction to execute and write on that folder by doing chmod -R 777 /usr/local/lib/python3.5/ which is usually not recommended but the problem you need pip to be able to read,write,execute anything in that folder.

Eliethesaiyan
  • 2,327
  • 1
  • 22
  • 35
  • This fixed the permission error I listed above (hence +1), but perhaps you missed the main problem I listed above, which it doesn't fix. Anyway I removed the listed part which is no longer relevant. – traveh May 24 '17 at 06:23
  • do you have these files enabled in your caffe Makefile.config # Uncomment to use Python 3 (default is Python 2) # PYTHON_LIBRARIES := boost_python3 python3.5m # PYTHON_INCLUDE := /usr/include/python3.5m \ # /usr/lib/python3.5/dist-packages/numpy/core/include ? – Eliethesaiyan May 24 '17 at 06:35
  • Yes, I have them, and just now I found that there isn't a `/usr/include/python3.5m' directory at all. There is a '/usr/include/python3.4m' directory, I don't understand why though, cause I installed Python 3.5.3 on the machine. – traveh May 24 '17 at 09:53
  • do you still have this error ython/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory? after installing python-3.5-dev,did you build caffe again?you need to delete build folder and repeat the whole process again.. – Eliethesaiyan May 24 '17 at 11:14
  • Yes, that is the error that I'm having, but I didn't install `python3.5-dev` because it doesn't seem to exist. I'm starting to think that it doesn't exist at all for Ubuntu 14.04. – traveh May 24 '17 at 11:41
  • you might be right....is there any specific reason you could not switch back to 3.4? seems to be available python3.4-dev? – Eliethesaiyan May 24 '17 at 12:00
  • becareful when you remove 3.5 use sudo apt-get remove python3-dev ,dont use autoremove – Eliethesaiyan May 24 '17 at 12:04
  • Caffe makefile includes header files from python 3.5. I'm now trying to go for 3.4 but I'm not sure it's supported. – traveh May 24 '17 at 12:21
  • Is it makefile itsself or Makefile.config?if its in makefile.config you can change then or use Anaconda to install 3.5 – Eliethesaiyan May 24 '17 at 15:42