I am trying to use the following package: https://github.com/vBaiCai/python-pesq and I am also using Pipenv and pyenv. I have installed 3.6-dev with pyenv and am using that with pipenv --python ~/.pyenv/versions/3.6-dev/bin/python3.
When I do pipenv install pypesq, I get a ton of errors, including:
file numpy.py (for module numpy) not found
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'pesq_core' extension
creating build/temp.macosx-10.15-x86_64-3.6
creating build/temp.macosx-10.15-x86_64-3.6/pypesq
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/shamoon/.pyenv/versions/3.6-dev/include/python3.6m -I/Users/shamoon/.pyenv/versions/3.6-dev/lib/python3.6/site-packages/numpy/core/include -c pypesq/pesq.c -o build/temp.macosx-10.15-x86_64-3.6/pypesq/pesq.o
pypesq/pesq.c:2:10: fatal error: 'arrayobject.h' file not found
#include "arrayobject.h"
^~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
I am on OS X if that matters. Any help.
I used pyenv to install Python 3.6-dev on Linux Mint 19.2 and I found two problems during installation pypesq:
1. It couldn't find arrayobject.h from module numpy
I used answer from Ubuntu forum fatal error: numpy/arrayobject.h: No such file or directory
I had to find folder with arrayobject.h and add it to environment variable CFLAGS so later C/C++ compiler will use it to find arrayobject.h- ie. (directly in terminal)
export CFLAGS="-I /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/ $CFLAGS"
I was installing pypesq for Python 3.6-dev but I used path to numpy installed in Python 3.7 and there was no problem.
BTW: To find it I used shell command locate which is not standard command but it works much faster then find
2. It couldn't find pesq.h
Instead of using module from pip server I used code from GitHub which was updated yesterday
pipenv install https://github.com/vBaiCai/python-pesq/archive/master.zip
After that I could import it in Python 3.6-dev but I didn't test if it works correctly.
Related
I'm trying to build the python interface of the stanford NLP on Ubuntu 12.04.5 LTS.
There are two steps required, the first of which is:
compile Jpype by running "rake setup" in 3rdParty/jpype
When doing so I get the following error:
In file included from src/native/common/jp_monitor.cpp:17:0:
src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
rake aborted!
Command failed with status (1): [cd JPype-0.5.4.1 && python setup.py build...]
The error messages says I'm missing jni.h, so as suggested here if I ran the command dpkg-query -L openjdk-7-jdk | grep "jni.h" getting /usr/lib/jvm/java-7-openjdk-amd64/include/jni.h.
I believe that means I do have jni.h on my system, so I'm very confused right now. What is causing the error? Can you suggest any fix?
Thanks for your help!
A FEW MORE INSIGHTS
Here is the instruction causing the error:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.7 -c src/native/common/jp_class.cpp -o build/temp.linux-x86_64-2.7/src/native/common/jp_class.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
In file included from src/native/common/jp_class.cpp:17:0:src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
It's coming from the compilation of JPype needed for the python interface. I do not know why but it includes paths that I don't have in my filesystem (i.e. -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux).
How can I configure these paths correctly?
The include paths specified do not include the path where jni.h is located.
From your grep, jni.h is located here: /usr/lib/jvm/java-7-openjdk-amd64/include/jni.h
The include paths specified in the gcc args are: -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include -I/usr/lib/jvm/java-1.5.0-sun-1.5.0.08/include/linux -Isrc/native/common/include -Isrc/native/python/include -I/usr/include/python2.7
Sounds to me that you are building with the wrong java? You have a java-1.5.0 install and a java-7-openjdk install - this one has the missing jni.h file.
Based on the following question, it seems like you can fix this by setting JAVA_HOME.
JPype compile problems
So before building use:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
This problem is a path problem (as said in the question and correctly answered by #vikramls).
Apparently when running the script for installing the python interface of the StanfordNLP if JPype is missing it will get installed with the following command:
python setup.py install
Now if you open the file setup.py you can see the following part which sets the java paths for a linux machine (I'm running on ubuntu):
def setupLinux(self):
self.javaHome = os.getenv("JAVA_HOME")
if self.javaHome is None :
self.javaHome = '/usr/lib/jvm/java-1.5.0-sun-1.5.0.08' # Ubuntu linux
# self.javaHome = '/usr/java/jdk1.5.0_05'
self.jdkInclude = "linux"
self.libraries = ["dl"]
self.libraryDir = [self.javaHome+"/lib"]
Clearly this path will not work on every machine, so there are 2 possible solutions:
Before running the installation script export a variable called JAVA_HOME with the location of your java installation. I.e. export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64 in my case.
As this page says you can set an automatic include variable for gcc with the following command export C_INCLUDE_PATH=some_path and that path should be set to where you java libraries are on your machine
I am experiencing an odd problem every time I try the set-up of pygit2. Below is what I run and the error generated.
$ python3 setup.py install
running install
running build
running build_py
running build_ext
building '_pygit2' extension
/usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/usr/local/include -Iinclude -I/usr/local/Cellar/python3/3.2.3/include/python3.2m -c src/pygit2.c -o build/temp.macosx-10.7-x86_64-3.2/src/pygit2.o
In file included from src/pygit2.c:32:
include/pygit2/error.h:6:10: fatal error: 'git2.h' file not found
#include <git2.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I think I have successfully installed libgit2 (the build and make finished fine). Maybe it is a path issue? I have set LIBGIT2 environment variable to the src directory in the libgit2 folder. Is that the right place?
I never installed libgit2, but the following might help:
If your distro's repository contains libgit2, I'll advice to remove what you have compiled before and install libgit2 (binaries) and libgit2-dev (headers etc.) packages from the repo. This will place binaries and sources to the right directories.
Otherwise, try symlinking git2.h to /usr/local/include
Following step worked for me:
brew install libgit2
It doesn't look like the LIBGIT2 variable took (could you show how you set the variable?) as the extra include directive uses /usr/local/include (which is the default).
The LIBGIT2 env var needs to be set to the prefix where the library was installed, typically /usr or /usr/local. It doesn't look like the library was installed to /usr/local as the compiler can't find it, so maybe you need export LIBGIT2=/usr before running setup.py.
You must be on macOS. Here is how I solved the problem:
brew install libgit2
If that isn't working because of Permission denied # dir_s_mkdir, just run the following command
sudo chown -R $(whoiam) $(brew --prefix)/*
In example.py file I have:
import libnet
but when I execute it via:
/opt/local/bin/python2.5 example.py
I'm getting "ImportError: No module named libnet"
How I tried to install it:
went to http://pylibnet.sourceforge.net/ and downloaded it
read the README file which said: compiling on Mac doesn't work, load it with Macports and use python 2.5
installed and used python 2.5
installed libnet via: sudo port install libnet11
everything seems to be fine
Just the error stays, it doesn't seem to be installed. What can i do now?
Thanks for any kind of help!
/Edit:
with: "sudo /opt/local/bin/python2.5 setup.py install", i'm getting:
Searching for libnet...
running install
running build
running build_ext
building 'libnet' extension
/Developer/usr/bin/llvm-gcc-4.2 -fno-strict-aliasing -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DLIBNET_MAJOR_VERSION=1 -DLIBNET_MINOR_VERSION=1 -DLIBNET_RELEASE=5 -DMAJOR_VERSION=2 -DMINOR_VERSION=0 -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/libnetmodule.c -o build/temp.macosx-10.7-x86_64-2.5/src/libnetmodule.o
In file included from src/context.c:110,
from src/libnetmodule.c:37:
src/builders.c: In function 'context_build_icmpv4_timestamp':
src/builders.c:726: error: 'n_time' undeclared (first use in this function)
src/builders.c:726: error: (Each undeclared identifier is reported only once
src/builders.c:726: error: for each function it appears in.)
src/builders.c:726: error: expected ';' before 'otime'
src/builders.c:727: error: expected ';' before 'rtime'
src/builders.c:728: error: expected ';' before 'ttime'
src/builders.c:735: error: 'otime' undeclared (first use in this function)
src/builders.c:735: error: 'rtime' undeclared (first use in this function)
src/builders.c:735: error: 'ttime' undeclared (first use in this function)
error: command '/Developer/usr/bin/llvm-gcc-4.2' failed with exit status 1
After you installed the C libraries with MacPorts, did you then install the python libnet wrapper you downloaded? If not, cd to the de-tarred pylibnet directory and try:
sudo /opt/local/bin/python2.5 setup.py install
Update: From your updated question, it now appears you have another version of the libnet C libraries installed in /sw which is the default location for packages installed by Fink. You should not attempt to mix package managers. Pick one - MacPorts, Fink, or Homebrew are the most popular on OS X - and stick with it. As a short term fix, you could probably edit the setup.py file to remove the search for /sw. You should at some point evaluate what packages you have installed with Fink and MacPorts, pick one, install any missing ports/packages in it, and entirely delete the other package system.
Question
How do I install SSL for Python 2.5 on Debian?
I have tried:
sudo easy_install ssl
But getting:
$ python setup.py build
looking for /usr/include/openssl/ssl.h
looking for /usr/include/krb5.h
running build
running build_py
running build_ext
building 'ssl._ssl2' extension
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/ssl
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./ssl/2.5.1 -I/usr/include/python2.5 -c ssl/_ssl2.c -o build/temp.linux-i686-2.5/ssl/_ssl2.o
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:45:33: error: bluetooth/bluetooth.h: No such file or directory
./ssl/2.5.1/socketmodule.h:46:30: error: bluetooth/rfcomm.h: No such file or directory
./ssl/2.5.1/socketmodule.h:47:29: error: bluetooth/l2cap.h: No such file or directory
./ssl/2.5.1/socketmodule.h:48:27: error: bluetooth/sco.h: No such file or directory
In file included from ssl/_ssl2.c:75:
./ssl/2.5.1/socketmodule.h:98: error: field ‘bt_l2’ has incomplete type
./ssl/2.5.1/socketmodule.h:99: error: field ‘bt_rc’ has incomplete type
./ssl/2.5.1/socketmodule.h:100: error: field ‘bt_sco’ has incomplete type
error: command 'gcc' failed with exit status 1
Solution
sudo apt-get install libbluetooth-dev
sudo rm /usr/lib/python2.5/site-packages/ssl/__init__.pyc
For reference, you must install libbluetooth-dev.
In fact, you shouldn't compile your own version of python ssl module for several reasons:
you won't get automatic security updates of your python ssl module;
you won't get smooth upgrade path if you decide to upgrade Debian system on your server.
The best way to obtain python ssl module is to install it from official Debian repositories using apt-get:
apt-get install python-openssl
Hope this helps.
I'm desperately trying to successfully install psycopg2 but keep running into errors. The latest one seems to involve it not being to find "stdarg.h" (see code below). However I can see with my own eyes that a file called stdarg.h exists at /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h (where it claims it can't find anything) so I've no idea what to do about it.
I'm running Mac OS 10.6.3 and within the last few days I've made sure I have all the latest OS developer tools.
I have Python 2.6.2 and PostgreSQL 8.4 if that makes any difference.
python setup.py install
running install
running build
running build_py
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.3-fat-2.6
creating build/temp.macosx-10.3-fat-2.6/psycopg
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPG_VERSION_HEX=0x080404 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -I/opt/local/include/postgresql84 -I/opt/local/include/postgresql84/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/MQ/MQ-tWOWWG+izzuZCrAJpzk+++TI/-Tmp-//ccakFhRS.out
error: command 'gcc' failed with exit status
I don't know your specific problem but i recommend you to install it using macports.
Installing psycopg2 is as simply as:
sudo port install py26-psycopg2
The following works for me:
$ mkvirtualenv --no-site-packages --distribute psycopg2_test
$ cd $VIRTUAL_ENV
$ pip install psycopg2
Notes
I installed my base Python via MacPorts.
The above commands make use of:
pip
virtualenvwrapper
virtualenv
I bootstrapped pip via the following:
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
UPDATE: I realize it seems like a lot of yak shaving, but learning how to use virtualenv and friends is an up-front investment that pays off pretty quickly, especially when dealing with projects that have a lot of dependencies.
I actually had a very similar problem as this (except with OSX Lion, Python 2.7) Can't install psycopg2 in virtualenv "error: stdarg.h: No such file or directory".
I ended up using this solution: https://stackoverflow.com/a/8834568/396327
Basically, uninstalling/reinstalling XCode from scratch (and a few more hacks to get it to recognize gcc-4.2).