libxml installe l'erreur en utilisant pip
C'est mon erreur:
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install lxml
Downloading/unpacking lxml
Running setup.py egg_info for package lxml
Building lxml version 2.3.
Building without Cython.
ERROR: /bin/sh: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 2.3.
Building without Cython.
ERROR: /bin/sh: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.6/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:4: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-jOhgvD-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6:
Building lxml version 2.3.
Building without Cython.
ERROR: /bin/sh: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
running install
running build
running build_py
running build_ext
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.6/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:4: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-jOhgvD-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6 failed with error code 1
Storing complete log in /home/zjm1126/.pip/pip.log
Que puis-je faire?
mise à jour:
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install lxml
Downloading/unpacking lxml
Running setup.py egg_info for package lxml
Building lxml version 2.3.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 2.3.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.6/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:4: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-NJw2ws-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6:
Building lxml version 2.3.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
running install
running build
running build_py
running build_ext
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.6/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:4: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-NJw2ws-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6 failed with error code 1
Storing complete log in /home/zjm1126/.pip/pip.log
le journal:
------------------------------------------------------------
/home/zjm1126/zjm_test/mysite/bin/pip run on Thu Mar 3 17:07:27 2011
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
running egg_info
creating pip-egg-info/MySQL_python.egg-info
writing pip-egg-info/MySQL_python.egg-info/PKG-INFO
writing top-level names to pip-egg-info/MySQL_python.egg-info/top_level.txt
writing dependency_links to pip-egg-info/MySQL_python.egg-info/dependency_links.txt
writing pip-egg-info/MySQL_python.egg-info/PKG-INFO
writing top-level names to pip-egg-info/MySQL_python.egg-info/top_level.txt
writing dependency_links to pip-egg-info/MySQL_python.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/MySQL_python.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'pip-egg-info/MySQL_python.egg-info/SOURCES.txt'
Installing collected packages: mysql-python
Running setup.py install for mysql-python
Running command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-XuVIux-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.6
copying _mysql_exceptions.py -> build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-i686-2.6/MySQLdb
creating build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-i686-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-i686-2.6
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.6 -c _mysql.c -o build/temp.linux-i686-2.6/_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: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-XuVIux-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6:
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.6
copying _mysql_exceptions.py -> build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-i686-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-i686-2.6/MySQLdb
creating build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-i686-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-i686-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-i686-2.6
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.6 -c _mysql.c -o build/temp.linux-i686-2.6/_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: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-XuVIux-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6 failed with error code 1
Exception information:
Traceback (most recent call last):
File "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/basecommand.py", line 130, in main
self.run(options, args)
File "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/commands/install.py", line 228, in run
requirement_set.install(install_options, global_options)
File "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/req.py", line 1043, in install
requirement.install(install_options, global_options)
File "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/req.py", line 559, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/__init__.py", line 249, in call_subprocess
% (command_desc, proc.returncode))
InstallationError: Command /home/zjm1126/zjm_test/mysite/bin/python -c "import setuptools;__file__='/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-XuVIux-record/install-record.txt --install-headers /home/zjm1126/zjm_test/mysite/include/site/python2.6 failed with error code 1
26 réponses
** assurez-vous que les paquets de développement de libxml2 et libxslt sont installés **
en supposant que vous exécutiez une distribution basée sur Debian
sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev
si vous installez pour Python 3 sur des distributions basées sur Debian, vous voudrez aussi installer python3-dev
.
cela a fonctionné pour moi:
yum install libxslt-devel libxml2-devel
dans le cas où vous utilisez Ubuntu/Lubuntu 13.04 ou Ubuntu 13.10 et que vous avez un problème avec "/ usr/bin / ld: cannot find -lz", vous devrez peut-être aussi installer le paquet zlib1g-dev:
sudo apt-get install -y zlib1g-dev
Mettre tous ensemble:
sudo apt-get install -y libxml2-dev libxslt1-dev zlib1g-dev python3-pip
sudo pip3 install lxml
Non vous manquez les fichiers d'en-tête Python. Cela se produit principalement sous Linux lorsque vous utilisez le système Python (il y a des raisons de ne pas faire , mais c'est une autre question).
vous avez probablement besoin d'installer un paquet, et il s'appelle probablement python-dev ou python-devel.
sudo yum install python-devel
ou
sudo aptitude install python-dev
Ou somesuch.
j'ai résolu ce problème en augmentant la ram de mon serveur.
Je n'utilisais que 512 Mo et quand je suis passé à 1 Go je n'ai eu aucun problème.
j'ai aussi installé manuellement tous les paquets avant cela pour tenter de corriger le problème, mais je ne suis pas sûr que ce soit une étape nécessaire.
sur Windows j'ai eu la même erreur sur windows lorsque j'ai essayé d'installer manuellement en Python 3.4 après qu'il ait été installé sur 3.3. J'ai finalement pu le résoudre en installant la roue et en exécutant pip à partir du répertoire Python34.
1) Télécharger la roue d'ici: http://www.lfd.uci.edu / ~gohlke / pythonlibs / #lxml
2) cd Python34\Scripts
3) pip.exe C:\Users\Home\Downloads\lxml- ......... .whl
il suffit de l'installer:
sudo apt-get install libxml2-dev libxslt-dev python-dev
Maintenant, vous pouvez l'installer avec l'outil de gestion des paquets pip:
pip install lxml
error: command 'gcc' failed with exit status 1
yum remove audit
yum install gcc
yum install libxslt-devel libxml2-devel
cd lxml-x.x.x
python setup.py build
python setup.py install
j'utilise Ubuntu 14.04 et cela résout la question pour moi""
sudo apt-get build-dep python3-lxml
sudo apt-get install libxml2-dev libxslt-dev python-dev
j'avais ce problème avec une installation pip de lxml. Mon instance de CentOS utilisait python 2.6 qui lançait cette erreur.
pour contourner cela j'ai fait ce qui suit pour exécuter avec Python 2.7:
- Run:
sudo yum install python-devel
- Exécuter
sudo yum install libxslt-devel libxml2-devel
- utilisez Python 2.7 pour exécuter votre commande en utilisant
/usr/bin/python2.7 YOUR_PYTHON_COMMAND
(Pour moi c'était/usr/bin/python2.7 -m pip install lxml
)
pymemcompat.h:10: fatal error: Python.h: 没有那个文件或目录
garçon, vous devriez afficher votre journal des erreurs avec LANG=C
ou les gens ne peuvent pas obtenir la cause réelle à partir de votre journal. Le journal ci-dessus, dit: Aucun fichier ou répertoire.
cela signifie que vous devez installer le paquet develop de Python. C'est habituellement "python-dev" sur Debian flavored distro, et "python-devel" sur RHEL flavored distro.
Toutes les réponses ci-dessus supposent que l'utilisateur a accès à un privilégié/compte root pour installer les bibliothèques nécessaires. Pour l'installer localement, vous devez suivre les étapes suivantes. A seulement montré la vue d'ensemble car les étapes peuvent être un peu impliquées selon les dépendances que vous pourriez manquer
1.Télécharger et compiler libxml2-2.9.1 & libxslt-1.1.28 (les versions peuvent changer)
2.Configurer chaque chemin d'installation pour libxml et libxslt doit être un répertoire local utilisant configure. Ex. ./configure --prefix=/home_dir/dependencies/libxslt_path
3.Exécuter make
puis make install
4.Télécharger et compiler lxml à partir de la source
cela fonctionne pour moi, 12.04, python2.7.6
sudo apt-get install libxml2 libxml2-dev libxslt1-dev
sudo pip install lxml
je sais que je suis en retard pour le spectacle,
mais cela aidera si rien d'autre ne fonctionne
mkdir ~/tmp
export TMPDIR=~/tmp
STATIC_DEPS=true easy_install-2.7 lxml
définir TMPDIR assurera que le build peut exécuter tout ce qu'il doit exécuter, et définir STATIC_DEPS lui dira de tirer dans sa propre libxml2 et libxslt2, au lieu d'utiliser les anciennes versions installées sur le serveur.
sudo apt install libxslt-dev libxml2-dev
et ensuite essayer de mettre à jour les setuptools de python
pip install -U pip setuptools
cela devrait le résoudre.
utilisant cygwin 64 avec Windows 8.
j'ai...
pip install lxml (...)
gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python3/python3-3.2.5-4.x86_64/build=/usr/src/debug/python3-3.2.5-4 -fdebug-prefix-map=/usr/src/ports/python3/python3-3.2.5-4.x86_64/src/Python-3.2.5=/usr/src/debug/python3-3.2.5-4 -I/usr/include/libxml2 -I/tmp/pip-build-b8ybku/lxml/src/lxml/includes -I/usr/include/python3.2m -c src/lxml/lxml.etree.c -o build/temp.cygwin-1.7.34-x86_64-3.2/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:8:22: fatal error: pyconfig.h: No such file or directory
compilation terminated.
/usr/lib/python3.2/distutils/dist.py:257: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.2m -c "import setuptools, tokenize;__file__='/tmp/pip-build-b8ybku/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-u3vwj8-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-b8ybku/lxml
j'ai tout essayé jusqu'à ce que je réalise qu'une nouvelle chaîne d'outils cygwin a foiré la logique python. cygwin installer un compilateur appelé "realgcc" qui n'est pas un réel gcc.
Solution
Installer gcc. Ex:
apt-cyg install gcc-g++
La seule chose qui a aidé pour moi a été
sudo apt-get install python3.5-dev
j'ai eu la même erreur sur ma machine Linux.Si vous allez à leur site web c'est dans leur documentation aussi bien.Donc, si vous obtenez ce genre d'erreur dans machine Linux , s'il vous plaît essayer ces commandes,
# apt install libxml2-dev libxslt-dev python-dev
# pip install lxml==3.4.4
J'utilise Ubuntu 12, et cela fonctionne pour moi:
sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
sudo apt-get install python-dev
sudo apt-get install lxml
si vous avez installé libxml2 et libxslt, vous devrez peut-être créer un lien symbolique entre libxml2 et le chemin libxslt vers python2.6 include path. Vous pouvez également essayer d'ajouter L'argument D'environnement INCLUDE. Parce que la commande gcc ne recherche que ce chemin: -I/usr/include/python2.6.
Le fichier ci-dessous a fonctionné pour moi sur windows https://pypi.python.org/pypi/lxml/3.3.3#downloads
sur osx 10.10.5 et dans un virtualenv, peut-être que vous pouvez résoudre ce problème comme ci-dessous:
sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include pip install -r lxml
je travaille sur une machine Windows. Et voici quelques conseils pour une installation réussie de lxml (avec python 2.6 et plus tard).
sont équipés comme suit:
- MingGW.
- libxml2 version 2.7.0 ou plus récente.
- libxslt version 1.1.23 ou ultérieure.
tous ne sont pas disponibles à un pip install
.
le binaire windows de libxml2 est trouvé ici .
libxslt se trouve ici .
après que vous avez terminé avec les deux ci-dessus,
: pip install lxml
.
une autre solution consiste à utiliser les versions stables de PyPI ou les binaires Windows non officiels de Christoph Gohlke ( trouvé ici ).
utilisant Windows 7 avec Cygwin, je suis tombé sur:
Compile failed: command 'gcc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitZsgdMQ.c -o tmp/xmlXPathInitZsgdMQ.o
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
Je l'ai fixé en installant mingw64-x86_64-libxslt