RuntimeWarning:模块"lxml.etree"的编译时版本2.6与运行时版本2.7不匹配 [英] RuntimeWarning: compiletime version 2.6 of module 'lxml.etree' does not match runtime version 2.7
问题描述
我正在使用python 2.7,并且尝试使用 lxml ,但是当我尝试使用lxml.etree时,我收到此错误:
I am using python 2.7 and I am trying to use lxml, but when I try using lxml.etree, I get this error:
RuntimeWarning:模块'lxml.etree'的编译时版本2.6与运行时版本2.7不匹配
RuntimeWarning: compiletime version 2.6 of module 'lxml.etree' does not match runtime version 2.7
然后出现此错误:
init lxml.etree中的文件"lxml.etree.pyx",第123行(src/lxml/lxml.etree.c:160385) TypeError:encode()参数1必须是不包含空字节的字符串,而不是unicode
File "lxml.etree.pyx", line 123, in init lxml.etree (src/lxml/lxml.etree.c:160385) TypeError: encode() argument 1 must be string without null bytes, not unicode
我尝试使用easy_install和pip安装
I have tried installing using easy_install and using pip
安装后,我看到此消息:
After installing, I see this message:
已安装/usr/lib/python2.6/site-packages/lxml-2.3.3-py2.6-linux-x86_64.egg
Installed /usr/lib/python2.6/site-packages/lxml-2.3.3-py2.6-linux-x86_64.egg
推荐答案
请确保您使用的是正确的easy_install和pip.安装easy_install和pip时,它们会通过符号链接与您用来安装它们的python版本匹配"到python版本.
Make sure you're using the right easy_install and pip. When easy_install and pip get installed, they're 'mated' with a version of python via a symlink by whatever version of python you used to install them.
如果您使用的是python-2.7,请确保使用easy_install-2.7或pip-2.7.赔率是您使用的pip与2.6配对的符号链接是'pip-> pip2.6'.
If you're using python-2.7, make sure you use easy_install-2.7, or pip-2.7. Odds are the pip you used was mated with 2.6 and it's symlink is 'pip -> pip2.6'.
如果您使用的是python2.7,请确保easy_install和pip的符号链接设置正确. (这应该简单到找到easy_install,然后将其替换为指向easy_install-2.7,然后运行easy_install pip,然后pip将替换它自己的链接.
If you're using python2.7, make sure easy_install and pip's symlinks are set correctly. (This should be as simple as finding easy_install, and replacing it to point to easy_install-2.7, then run easy_install pip and pip will replace it's own link.
要用正确的版本替换easy_install:
To replace easy_install with the correct version:
wget http://peak.telecommunity.com/dist/ez_setup.py
python2.7 ez_setup.py
那应该用一个使用正确的python版本的版本替换现有的easy_install.使用它以及您需要的任何其他模块重新安装pip.
That should replace your existing easy_install with one that uses the correct python version. Reinstall pip using it, and whatever other modules you need.
这篇关于RuntimeWarning:模块"lxml.etree"的编译时版本2.6与运行时版本2.7不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!