I'm trying to install ansible-pylibssh on an Apple Silicon based Mac.
ansible is already installed.
When running pip3 install ansible-pylibssh I get the following error:
pip3 install --user ansible-pylibssh 1 ✘ took 3s at 00:36:15
Collecting ansible-pylibssh
Using cached ansible-pylibssh-1.0.0.tar.gz (97 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ansible-pylibssh
Building wheel for ansible-pylibssh (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for ansible-pylibssh (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
[1/1] Cythonizing /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.pyx
running build_ext
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.c -o /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.o
/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.c:757:10: fatal error: 'libssh/libssh.h' file not found
#include "libssh/libssh.h"
^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ansible-pylibssh
Failed to build ansible-pylibssh
ERROR: Could not build wheels for ansible-pylibssh, which is required to install pyproject.toml-based projects
However libssh is already installed:
brew install libssh
Warning: libssh 0.10.4 is already installed and up-to-date.
To reinstall 0.10.4, run:
brew reinstall libssh
I have tried reinstalling ansible, libssh, none of them worked.
I'm having the same problem as you, this issue was finally solved today.
When i manually building and installing from source, still run into this problem:
#include "libssh/libssh.h"
^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
This is because the libssh library was not discovered by clang, so we manually added a softlink to solve it.
Find out the lib dir:
% clang -E -x c - -v < /dev/null
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
......
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
......
Create a softlink for libssh:
% cd /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
% sudo ln -s /opt/homebrew/Cellar/libssh/0.10.4/include/libssh/ libssh
Rebuilding and installing from source, Worked!
Install libssh:
brew install libssh
Use a python virtual environment :
python3 -m venv .venv
source .venv/bin/activate
EDIT:
Install with correct compiler flags:
CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh" pip install ansible-pylibssh
Thanks, #webknjaz!
OLD Additional steps not needed (preserved for history):
Install tox build tool:
pip install 'tox >= 3.19.0'
Build from source on ARM-based Macs, per the ansible-pylibssh docs:
#git clone https://github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
# or, if you use SSH:
git clone ssh://git#github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
cd ~/src/github/ansible/pylibssh
Use libraries installed by brew with clang:
export CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh"
Build ansible-pylibssh:
tox -e build-dists
Install built ansible-pylibssh wheel:
pip install ~/src/github/ansible/pylibssh/dist/ansible_pylibssh*.whl
Additional resources that lead to this answer:
Kristof Rado's answer
ansible/pylibssh GitHub issue 207 provides background on why this package is not available for macOS on ARM from PyPi (symlink/softlink to point to the libraries did not help. Correct compiler flags were the needed answer.)
If you prefer not to work with a virtual environment, this may work: replace pip commands python3 -m pip --user and python commands with python3.
The problem was with the package not my computer.
It seems that Github Actions are not available for ARM Macs so no dists were built for this platform.
Manually building and installing from source worked:
$ git clone https://github.com/ansible/pylibssh.git
$ cd pylibssh
$ pip install tox
$ tox -e build-dists
Installing:
cd dist
pip3 install ansible_pylibssh-1.0.1.dev47+g75289d4-cp39-cp39-macosx_12_0_arm64.whl
Defaulting to user installation because normal site-packages is not writeable
Processing ./ansible_pylibssh-1.0.1.dev47+g75289d4-cp39-cp39-macosx_12_0_arm64.whl
Installing collected packages: ansible-pylibssh
Successfully installed ansible-pylibssh-1.0.1.dev47+g75289d4
Related
Before I start the question, I tried to solve issue with this post, but it did not work: (Link)
I am using mac (M1 air).
I tried to install pyaudio, so I ran pip install pyaudio.
Then, I got the following error about not finding portaudio.h:
pip install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /Users/sunwoojeong/anaconda3/bin/python /Users/sunwoojeong/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/tmpzv_dfxv_
cwd: /private/var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/pip-install-y3rg1882/pyaudio_1d880ef087ea42298d89af097d6745ed
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-38
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-38
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-cpython-38
creating build/temp.macosx-10.9-x86_64-cpython-38/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/sunwoojeong/anaconda3/include/python3.8 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-38/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio which use PEP 517 and cannot be installed directly
So, After some research I tried to install and link portaudio first like this:
brew install portaudio
brew link portaudio
pip install pyaudio
Since brew link portaudio returns Warning: Already linked: /opt/homebrew/Cellar/portaudio/19.7.0, I expected that portaudio was installed succesfully and pyaudio should have no issue with portaudio.h file. However, even after installing it, and after explicitly setting the path to the portaudio folder, the pip install command still returns this error.
Here is the pip commands I tried (they all return the same error):
pip install pyaudio
pip install --global-option='build_ext' --global-option="-I$(brew --prefix)/include" --global-option="-L$(brew --prefix)/lib" pyaudio
pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
Has anyone had similar issue and solved it before when installing a python module with some c-lang file?
Some suggestions:
Try the answer provided here. It suggests you use --no-binary: all: like so:
sudo pip3 install pyaudio --no-binary :all:
Or:
python -m pip install --upgrade pip
python -m pip install --no-use-pep517 pyaudio
The other option is to downgrade pip. While I haven't used pyaudio before, I have gotten this error with other libraries and one of the above solutions usually fixed it. There is a good possibility that these won't work for you, and there are a lot of different ways this issue can be fixed that are mentioned in SO. One of those solutions will eventually work for you.
I think a fix is coming soon. In the meantime, you should be able to workaround the issue by doing this:
export CFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib”
pip install pyaudio
Good luck!
I'm trying to use OpenEXR module on blender's 3.1.2 script but I can't import it. I can import it using my python 3.8.10 installed.
I first install it using :
pip install openexr
pip3 install openexr
sudo apt install libopenexr-dev
And it works fine on my python 3.8.10 command line.
I then tried to install it using the blender's python version :
./python3.10 -m pip install openexr
but I get that error from gcc :
Defaulting to user installation because normal site-packages is not writeable
Collecting openexr
Using cached OpenEXR-1.3.8.tar.gz (11 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: openexr
Building wheel for openexr (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Looking for libOpenEXR...
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
copying Imath.py -> build/lib.linux-x86_64-3.10
running build_ext
building 'OpenEXR' extension
creating build/temp.linux-x86_64-3.10
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/sqlite/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/bzip2/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/lzma/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/zlib/include -fPIC -fPIC -fPIC -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR -I/opt/local/include/OpenEXR -I/usr/include/Imath -I/usr/local/include/Imath -I/opt/local/include/Imath -I/snap/blender/2106/3.1/python/include/python3.10 -c OpenEXR.cpp -o build/temp.linux-x86_64-3.10/OpenEXR.o -g -DVERSION="1.3.8"
OpenEXR.cpp:1:10: fatal error: Python.h: No such file or directory
1 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for openexr
Running setup.py clean for openexr
Failed to build openexr
Installing collected packages: openexr
Running setup.py install for openexr ... error
error: subprocess-exited-with-error
× Running setup.py install for openexr did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Looking for libOpenEXR...
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
copying Imath.py -> build/lib.linux-x86_64-3.10
running build_ext
building 'OpenEXR' extension
creating build/temp.linux-x86_64-3.10
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/sqlite/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/bzip2/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/lzma/include -I/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/zlib/include -fPIC -fPIC -fPIC -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR -I/opt/local/include/OpenEXR -I/usr/include/Imath -I/usr/local/include/Imath -I/opt/local/include/Imath -I/snap/blender/2106/3.1/python/include/python3.10 -c OpenEXR.cpp -o build/temp.linux-x86_64-3.10/OpenEXR.o -g -DVERSION="1.3.8"
OpenEXR.cpp:1:10: fatal error: Python.h: No such file or directory
1 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> openexr
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Any way to solve that issue so I can use OpenEXR on blender or make blender to use python installed instead of it's own version ?
I'm on ubuntu 20.04
I finally get it to work by copying the files from OpenEXR-1.3.8 into the folder of the python executable and then installing OpenEXR.
1- Download OpenEXR-1.3.8 from here.
2- Copy all the files into your blender python executable, for me it was :
/homa/jros/Downloads/blender-2.90.0-linux64/2.90/python/bin
3- Run the executable with those parameters -m setup.py install like so
./python3.7m -m setup.py install
and it should work. You might need to install those as well :
sudo apt install python3.10-dev
pip install openexr
pip3 install openexr
sudo apt install libopenexr-dev
I'm trying to run pip install zbar and for some reason I can't seem to find an answer to solve this dependency issue. Any help would be extremely appreciated. See traceback below:
Downloading/unpacking zbar
Downloading zbar-0.10.tar.bz2
Running setup.py
egg_info for package zbar
Installing collected packages: zbar
Running setup.py install for zbar
building 'zbar' extension
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-2.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
#include <zbar.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
running install
running build
running build_ext
building 'zbar' extension
creating build
creating build/temp.macosx-10.9-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-2.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
include <zbar.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
In my case I was running Ubuntu and had to install libzbar-dev package:
sudo apt-get install libzbar-dev
$ brew install zbar
and after that
$ pip install zbar
The header files will then be found (zbar.h)
Encountered this problem again after 2 years... this is what worked for me
LDFLAGS=-L/usr/local/lib/ CPATH=/usr/local/include/ pip install zbar
In case others run into this issue aren't able to use pip to install zbar for python:
Install zbar: brew install zbar
Install PIL: brew install pillow
Download zbar source: https://pypi.python.org/pypi/zbar
Unzip zbar: tar -xjvf zbar-0.10.tar.bz2
Install: python setup.py install --user
I encountered this issue recently while attempting to launch a service locally from Mac OS in a virtual environment, that imports zbar in the python application. The service was still running python2.7.
Having the service running in a virtual environment I was unwilling to attempt anything that required global system changes.
I solved it by having to install zbar through Homebrew (globally). Then exporting flags or implicit rules used in the C compiling "recipe" to the virtual environment. Finally I installed a similar library to the zbar dependancy in the virtual environment.
$ brew install zbar
Then when sourced in the virtual environment I do the following to change the implicit rules in the c compilation recipe:
$ export LDFLAGS="-L$(brew --prefix zbar)/lib"
$ export CFLAGS="-I$(brew --prefix zbar)/include"
Finally I install a light version of zbar inside the venv:
$ pip install zbarlight
After the above, with the additional dependancy of pyzbar below included in my requirements.txt I am able to import zbar with python2.7 in the virtual environment.
pyzbar==0.1.7
Testing the import in the virtual environment:
$ python
>>> import zbar
>>>
Hope this helps someone in the future. I struggled quite a bit in getting this to work and resources regarding zbar are fairly scarce.
Calling
pip install SQLAlchemy
I get an error:
lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory
As far as I know, I have the correct Python version (2.7.3) and OS (Ubuntu 12.04) (See below.) for this to work. Am I doing anything wrong?
The install does work as
pip install --global-option='--without-cextensions' SQLAlchemy"
but I want the C extensions.
Full output:
root#mycomputer:/# pip install SQLAlchemy
Downloading/unpacking SQLAlchemy
Downloading SQLAlchemy-0.8.3.tar.gz (3.9Mb): 3.9Mb downloaded
Running setup.py egg_info for package SQLAlchemy
warning: no files found matching '*.jpg' under directory 'doc'
no previously-included directories found matching 'doc/build/output'
Installing collected packages: SQLAlchemy
Running setup.py install for SQLAlchemy
building 'sqlalchemy.cprocessors' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c lib/sqlalchemy/cextension/processors.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/processors.o
lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory
compilation terminated.
***************************************************************************
command 'gcc' failed with exit status 1
WARNING: The C extension could not be compiled, speedups are not enabled.
Failure information, if any, is above.
Retrying the build without the C extension now.
***************************************************************************
warning: no files found matching '*.jpg' under directory 'doc'
no previously-included directories found matching 'doc/build/output'
***************************************************************************
WARNING: The C extension could not be compiled, speedups are not enabled.
Plain-Python build succeeded.
***************************************************************************
Successfully installed SQLAlchemy
Cleaning up...
root#mycomputer:/#
Python Version:
root#mycomputer:/#python -V
Python 2.7.3
root#mycomputer:/#
Ubuntu Version:
root#mycomputer:/#cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
root#mycomputer:/#
You need to install the python-dev (or similar name) package for your version of Python. It includes all the header files needed to compile C extensions. These files are (unfortunately) not included in the default python packages.
For Ubuntu, the command is
sudo apt-get install python-dev
or
sudo apt-get install python3-dev
depending on which version you're using.
sudo apt-get install python-dev -y
I am trying to set up a virtualenv for a Django project. It needs MySQL-python. I'm trying to replicate the production environment, which uses Python 2.5. My Ubuntu desktop has Python 2.5. I can install the Python 2.5 virtualenv with virtualenv --python=/usr/bin/python2.5 .... However when I try to pip install MySQL-python, I get this output:
$ pip install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.5 -c _mysql.c -o build/temp.linux-i686-2.5/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX
In file included from _mysql.c:29:
pymemcompat.h:10: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
I have installed the python-dev Ubuntu deb package, but that's for Python 2.6.
How else can I get MySQL-python installed?
I had this same problem on an Ubuntu box. Prior to installing MySQL-python via pip, I needed to compile the module and dependencies from source using the following command:
sudo apt-get build-dep python-mysqldb
see this article - http://theviceprogrammer.com/?p=238
Actually, found a solution, I enabled the Dead Snakes - old python version repository, then I could aptitude install python2.5-dev, and then pip install MySQL-python worked
Instead of using pip or easy_install, you can use apt-get:
sudo apt-get install python-mysqldb
Requiring from source as per adam's reply wasn't require for me, on Ubuntu 12.04 w/ Python 2.5