Python pip can't seem to find Python.h despite python-dev installed - python-2.7

I am currently trying to install getch, a simple python package and have run into quite a bit of difficulty. I recently installed pypy in a kind of messy way (I wanted to get numpy with pypy working, which was a considerable pain) so that might have to do with the problem I'm having.
Okay, so I try to run
sudo pip install getch
and I get the error...
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and as a bonus, a character encoding error.
This is the error that folks get when they don't have python-dev installed. However, I do. I attempted to work around this issue, by downloading the package and installing it manually.
sudo python setup.py install
also gave me the gcc error from above. I have gcc installed, and x86_64-linux-gnu-gcc works in terminal fine. I made a simple hello world program in c that simply includes Python.h. That worked fine as well. After remove --purging pypy, python, and python-dev from my system, I re-installed just python and python-dev and I still have the same silly issue.
Anyone have any thoughts?
Here's a pastebin of the exact error I'm getting. pastebin.com/mjRdADZx

You need to manually download the Python 2 version and install it. The version downloaded by pip is for Python 3.
The clue is this line:
Downloading/unpacking getch
Downloading getch-1.0.tar.gz # This is the Python 3 package
Running setup.py egg_info for package getch
Installing collected packages: getch
Running setup.py install for getch
building 'getch' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -c getchmodule.c -o build/temp.linux-i686-2.7/getchmodule.o
getchmodule.c: In function ‘getch_getche’:
getchmodule.c:36:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: In function ‘getch_getch’:
getchmodule.c:43:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: At top level:
getchmodule.c:54:15: error: variable ‘getchmodule’ has initializer but incomplete type
getchmodule.c:55:4: error: ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function)
The Python 2 version is also 1.0, but the file name is getch-1.0-python2.tar.gz. You can download it directly from the index.
Once downloaded, extract the archive and then python setup.py install from within the extracted directory.

Related

django channels install error

I am trying to create a one to one real-time messaging system using Django. Upon searching I found out about django-channels. So i created a virtual env with python 3.5 and latest Django but when I do pip install channels I get :
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/kshitij/Documents/projects/personal/maker/venv/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
probably because of missing python headers so i did : sudo apt-get install python3-dev but it still shows the same error. What should I do?
pip version: 18
python version: 3.5
django version: 2.1
I tried doing sudo apt-get install python3-dev but getting:
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
Verify your pip is not pip and its pip3.
You may also try installing sudo apt install python3.X-dev.
For you, it's sudo apt install python3.5-dev
Try installing the Linux compiler and python3-dev:
sudo apt install gcc
sudo apt install python3-dev
pip install channels
The last error may indicates you have an issue caused by many python versions installed on your system (see this answer). You should make sure you don't have incomplete or corrupted python installation on your system (did you already compiled Python by yourself?). In addition, make sure the package python3 is correctly installed or sudo apt-get install python3-dev cannot succeed.
In addition, you may try to locate Python.h on your system. Make sure each Python.h on your system correspond to a valid python setup (you may have one for python 2 and one more for python 3).

virtualenv python-ldap install error

Please don't call this a duplicate.
All the answers have so far only 'solved' the problem by installing the ldap and other development packages globally, which doesn't solve the problem of not being able to install the python-ldap package in the virtual environment.
Examples include:
How do I install python-ldap in a virtualenv on Ubuntu?
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
I am using ubuntu 14.04, python 2.7 and flask in my virtual environment.
When I run pip install python-ldap, I receive the following error.
copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-2.7/ldap
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
running egg_info
writing requirements to Lib/python_ldap.egg-info/requires.txt
writing Lib/python_ldap.egg-info/PKG-INFO
writing top-level names to Lib/python_ldap.egg-info/top_level.txt
writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules/LICENSE'
writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
running build_ext
building '_ldap' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/Modules
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.21 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o
Modules/LDAPObject.c:18:18: fatal error: sasl.h: No such file or directory
#include <sasl.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/kmertig/hd_request/hd_request/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-V4vhsl/python-ldap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NIR67Y-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kmertig/hd_request/hd_request/include/site/python2.7/python-ldap" failed with error code 1 in /tmp/pip-build-V4vhsl/python-ldap
If I try to pip install any of the suggested dev libraries so that they are inside my virtual environment, I get the following error.
Could not find a version that satisfies the requirement libsasl2-dev (from versions: ) No matching distribution found for libsasl2-dev
I can install all this stuff globally just fine, but that just plain defeats the purpose of using virtualenv.
I would really like to find a meaningful, virtualenv solution, since all I have been able to find is non-virtualenv solutions for a virtualenv question.
Thanks.
The Python package python-ldap requires some other libs (libsasl2-dev, …) which are not python libs (so you can't use pip to install them). So, to use them, you have to install them. Two solutions:
use your package manager to install them (ex.: apt-get) ;
download their source code and compile them locally (in your virtualenv) (useful for some libs in special cases).
Maybe you can try the second solution?

configure: error: no boost.filesystem library found

So I'm trying to install ncmpcpp though this github, and the first step is to run the sh autogen.sh script. I've run into a few missing libraries, etc., but I've been able to install them and move on- up until now. I've done some searching and installed a handful of things I thought would help fix it, but to no avail.
sudo apt-get install libboost1.55-all-dev
sudo apt-get install libboost-system-dev
sudo apt-get install libboost-system1.54-dev
sudo apt-get install libboost1.54-dev
sudo apt-get install libboost-filesystem-dev
sudo apt-get install libboost-filesystem-dev libboost-thread-dev
Truth is I don't know enough about Boost or what I'm missing to fix it on my own.
This is where the problem starts:
checking for boost/filesystem.hpp... yes
checking for main in -lboost_filesystem-mt... no
configure: error: no boost.filesystem library found
edit: Here are the surrounding lines to '-lboost_filesystem-mt' in the config.log file.
configure:15510: checking for main in -lboost_filesystem-mt
configure:15529: g++ -o conftest -g -O2 -std=c++0x conftest.cpp -lboost_filesystem-mt >&5
/usr/bin/ld: cannot find -lboost_filesystem-mt
collect2: error: ld returned 1 exit status
configure:15529: $? = 1
configure: failed program was:
| /* confdefs.h */
... and then it goes on to describe the confdefs.h file.
Remove these linkes from configure.ac (section "setting boost environment"):
AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=-mt])
AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=-mt]])
Long ago, the Boost libraries used to have a -mt suffix to indicate that they were multithreading-aware. Debian/Ubuntu dropped this years ago. Maybe other distributions retained it. The Boost library names were never very standardized in any case, which is why configure scripts often try do deal with them, often in broken ways.
You can either remove these two lines or call it like this:
$ BOOST_LIB_SUFFIX="" ./autogen.sh
The proper fix is to convert the script to use the Boost macros from the Autoconf Archive.

error happens during installation of pyipopt in Ubuntu 12.04

having installed IPOPT and trying to install pyipopt in Ubuntu 12.04 box, I encountered the following error:
python setup.py install
results in the following error:
running install
running build
running build_py
running build_ext
building 'pyipoptcore' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/coin/ -I/usr/include/python2.7 -c src/callback.c -o build/temp.linux-x86_64-2.7/src/callback.o
In file included from src/callback.c:36:0:
src/hook.h:5:29: fatal error: IpStdCInterface.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
any ideas ?
this is the interface for the ipopt library which is required to compile. as stated in the setup.py file
# You will probably have to edit this file in unpredictable ways
# if you want pyipopt to work for you, sorry.
the easiest way to handle this is to adjust the setup.py accordingly:
# When I installed Ipopt from source, I used the
# --prefix=/usr/local
# option, so this is where I want pyipopt to look for my ipopt installation.
# I only installed from source because the ipopt packaging
# for my linux distribution was buggy,
# so by the time you read this the bugs have probably been fixed
# and you will want to specify a different directory here.
IPOPT_DIR = '/usr/local/'
adjust IPOPT_DIR to the path where the library has been installed on your system, which of course should has been conducted anyway.
EDIT:
If you are installing from source, just use --prefix=/usr/local for the configure script and compile and install the library by running make; sudo make install. Then you don't have to change the setup.py file.

Installing gevent on Mavericks (Enthought Canopy python)

Has anyone had any luck building gevent 1.0 in Mavericks?
I've tried the following:
pip (as recommended on the gevent package index)
easy_install
compiling from source
I keep getting the same error when building 'gevent.core':
...
building 'gevent.core' extension
creating build/temp.macosx-10.6-i386-2.7/gevent
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk
Please check your Xcode installation
gcc -DNDEBUG -g -O3 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -U__llvm__ -
DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CHECK_ENABLE=0 -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0
-DEV_PERIODIC_ENABLE=0 -Ibuild/temp.macosx-10.6-i386-2.7/libev -Ilibev -
I/Applications/Canopy.app/appdata/canopy-1.2.0.1610.macosx-
x86/Canopy.app/Contents/include/python2.7 -c gevent/gevent.core.c -o build/temp.macosx-
10.6-i386-2.7/gevent/gevent.core.o
clang: warning: no such sysroot directory: '/Developer/SDKs/MacOSX10.6.sdk'
In file included from gevent/gevent.core.c:17:
/Applications/Canopy.app/appdata/canopy-1.2.0.1610.macosx-
x86/Canopy.app/Contents/include/python2.7/Python.h:33:10: fatal error:
'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
error: command 'gcc' failed with exit status 1
Seems to be a problem with XCode. I made sure I have the XCode (v. 5.0.2) command line tools installed with:
xcode-select --install
But that didn't seem to change anything. Apparently I'm not alone with this problem (a missing /Developer/SDKs/MacOSX10.6.sdk), but I'd like to stick with Enthought's Canopy version of python if I can (and have already spent too much time combing the Apple Developer site to try download MacOSX10.6.sdk directly).
Any suggestions that don't involve starting over with a macport'ed python? Thanks!
IIUC, Apple pulled a fast one on the latest XCode, such that gcc is no longer actually gcc, but is symlinked to clang, which is not compatible with standard Pythons, including Canopy's.
It should work better if you install Xcode 3.2.1 Developer Tools from https://developer.apple.com/downloads/index.action
For me the hint on gevent website helped:
pip install cython git+git://github.com/gevent/gevent.git#egg=gevent