I'm using Xcode. I got an error on this new mac:
'Python.h' file not found.
At line:
#include <Python.h>
When I type sudo find / -name "Python.h" in command line, I can see quite a few version of it exist, even inside Xcode.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h
Anyone have any idea of what is going on? Is that I am not setting up Xcode properly?
You need to set the include path where 'Python.h' exists.
For detailed operation, please refer the question "How to set include path in xcode project" at following URL.
How to set include path in xcode project
Related
I'm very new in Linux Terminal
As I know if I edit (nano ~/.bashrc) bashrc and do export path
then all files will connect with exported PATH
So I did
enter image description here
My bashrc
and did source ~/.bashrc
after that I write the Mujoco
my command was$python3 -c "import mujoco_py"
enter image description here
FATAL EERror
And then I get fatal error.So I checked that directory
Cute header files
enter image description here
There are Xlib.h (2,3)
I'm so confuse about this matter, How can I solve it?
(I had edit all files' directory to
#include /usr/include/X11/Xlib.h ...
this had worked but This is not a good idea my think
and after that I got GL directory error again .. )
From a related post, one installed package matplotlib-cpp through microsoft /
vcpkg . However, when running a simple example,
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main() {
plt::plot({1,3,2,4});
plt::show();
}
an error returned stating that
Error C1083 Cannot open include file: 'Python.h': No such file or directory Examples
..\vcpkg\installed\x64-windows\include\matplotlibcpp.h 5
I have tried the methods in:
can't include Python.h in visual studio
psycopg: Python.h: No such file or directory and Cygwin gcc issue - cannot find Python.h (which didn't apply since vs managed python environment itself, and there wasn't python-dev option)
A very similiar post C++: matplotlibcpp.h and Python.h linker error also indicated the same issue in Ubuntu environment.
In matplotlibcpp.h file, it mentioned that
// Python headers must be included before any system headers, since
// they define _POSIX_C_SOURCE
#include <Python.h>
What did it mean? How to link python.h and a matplotlibcpp.h in Visual Studio 2019?
Updates:
I was able to locate "Python.h" and "numpy/arrayobject.h" in MS python folder. However, when I manually added those three ".h" files into the project header folder, the issue wasn't resolved. Especially, when I manually fixed the locations in "matplotlibcpp.h", the "Python.h" in ""numpy/arrayobject.h" still could not be located.
I am on MacOS 10.13.3 (17D47) with Python 2.7.14. I am in the process of building caffe w/ python. The project is CPU only. I am able to build caffe through make run test however, after attempting make pycaffe I get an error. This is the result:
touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
In file included from python/caffe/_caffe.cpp:17:
In file included from ./include/caffe/caffe.hpp:12:
./include/caffe/net.hpp:41:5: warning: unused typedef 'INVALID_REQUESTED_LOG_SEVERITY' [-Wunused-local-typedef]
LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() "
^
/usr/local/include/glog/logging.h:943:30: note: expanded from macro 'LOG_EVERY_N'
INVALID_REQUESTED_LOG_SEVERITY); \
^
1 warning generated.
ld: library not found for -lboost_python
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [python/caffe/_caffe.so] Error 1
I have a Makefile.config that calls out boost-python from the brew install set as:
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/Cellar/boost-python/1.67.0/lib
My two initial questions are:
1)Am I not allowed to link to the boost library using the system python? 2)What is the correct way to tell make to grab boost-python?
I was actually having the same problem and couldn't find any answers for days. However, I found this question: Build caffe with Python ( cannot find -lboost_python3 ) .
That question is for python3, but I'm using python2.7 . Basically, I went into the Makefile (not Makefile.config), searched for boost_python, and changed it to boost_python27 . I did the following steps:
vim Makefile
use vim command :?boost_python (there should only be 1 occurrence)
changed PYTHON_LIBRARIES ?= boost_python python2.7
to PYTHON_LIBRARIES ?= boost_python27 python2.7
ran the command sudo make pycaffe
I hope this helps you!
Goto Makefile (and not the .config file) and change the name of the ld library to python27.
I'm getting an error while trying to install FEnicS on Mac OS X 10.11.6. I've read the responses to similar questions on this website, and have tried the suggested solutions, but I must be doing something wrong.
On running the command:
curl -s https://fenicsproject.org/fenics-install.sh | bash
I get an error while the cython package is being installed:
[cython] Building cython/e2t4ieqlgjl3, follow log with:
[cython] tail -f /Users/sophiaw/.hashdist/tmp/cython-e2t4ieqlgjl3-1/_hashdist/build.log
[cython|ERROR] Command '[u'/bin/bash', '_hashdist/build.sh']' returned non-zero exit status 1
[cython|ERROR] command failed (code=1); raising.
The message from build.log is:
Checking .pth file support in
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
/Users/sophiaw/.hashdist/bld/python/pf77qttkbtzn/bin/python -E -c pass
TEST FAILED:
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
does NOT support .pth files error: bad install directory or
PYTHONPATH
You are attempting to install a package to a directory that is not on
PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
and your PYTHONPATH environment variable currently contains:
'/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/Python.framework/Versions/2.7/lib/python2.7/site-packages:'
Here are some of your options for correcting the problem:
You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files
You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python
and want to use the package(s) you are installing.)
You can set up the installation directory to support ".pth" files by using one of the approaches described here:
https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
I've tried adding this to the bash_profile, but get the same error:
export PYTHONPATH=/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages:$PYTHONPATH.
How can I fix this error?
This was resolved by the fenics support group. to install FEniCS on OS X, Docker is a more convenient option.
I compiled caffe on a mac running OSX 10.9.5 and I know trying to compile pycaffe. When I run make pycaffe in the caffe root folder, I get:
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:1:10: fatal error: 'Python.h' file not found
#include <Python.h> // NOLINT(build/include_alpha)
^
1 error generated.
make: *** [python/caffe/_caffe.so] Error 1
how can I fix this?
Perhaps is something wrong with Makefile.config. How do I know what is my PYTHONPATH?
Looking at the comments, I see that you use Anaconda. In Makefile.config, you should uncomment the lines dedicated to Anaconda:
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
Python.h is in $(ANACONDA_HOME)/include/python2.7 as you can see running sudo find / -name 'Python.h'.
I met this problem too.
I have set the PYTHON_INCLUDE PATH
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python2.7
But it still can't find the Python.h
So I just give the include path manually to the compiler as follows:
export CPLUS_INCLUDE_PATH=/home/woolawren/anaconda2/include/python2.7/:$CPLUS_INCLUDE_PATH
if you don't use anaconda2, you can use:
export CPLUS_INCLUDE_PATH=/usr/include/python2.7:$CPLUS_INCLUDE_PATH
I have successfully done "make pycaffe" by doing this.
I just finished a tedious Caffe install on Arch Linux; hopefully my install notes (link below) will help others.
While specific to my Caffe install, those notes address the "Python.h" install error (this Question), as well as a downstream issue mentioned in another SO question,
Import caffe error.
https://stackoverflow.com/questions/28177298/import-caffe-error
My gist file (notes):
Caffe Installation Notes
https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213
I uncommented the below code in Makefile.config
PYTHON_INCLUDE := /usr/include/python3.5m \
/usr/lib/python3.5/dist-packages/numpy/core/include
Then did sudo make pycaffe.
It worked.