gpt4 book ai didi

python - 导入错误 : No module named _io in ubuntu 14. 04

转载 作者:IT老高 更新时间:2023-10-28 12:34:50 28 4
gpt4 key购买 nike

我刚刚安装了 ubuntu 14.04LTS,我正在尝试使用 pip,但我得到了以下回溯:

(nlmanagement)psychok7@Ultrabook:~/code/work/nlmanagement$ pip freeze
Traceback (most recent call last):
File "/home/psychok7/code/work/venv/nlmanagement/bin/pip", line 9, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip')()
File "/home/psychok7/code/work/venv/nlmanagement/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/psychok7/code/work/venv/nlmanagement/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
File "/home/psychok7/code/work/venv/nlmanagement/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 1989, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/psychok7/code/work/venv/nlmanagement/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 10, in <module>
from pip.backwardcompat import walk_packages, console_to_str
File "/home/psychok7/code/work/venv/nlmanagement/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/backwardcompat.py", line 77, in <module>
from urllib2 import URLError, HTTPError
File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 79, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: No module named _io

有什么想法吗?我试过 sudo apt-get install python3-pipsudo apt-get install python-pip

最佳答案

我遇到了同样的问题。这发生在 Ubuntu - 14.04 和虚拟环境的 Python 版本 - 2.7.3

在调试了一天后,在这里发布我的答案,希望对以后的访问者有所帮助。

我发现 io.py 正在调用 _io 模块。我认为 _io 模块是解释器的内部模块,因此,只需将环境中的 python 二进制文件替换为较新的版本即可。

(在我的例子中,Cloudera Manager 5.x Agent 在 ubuntu 14.04 上的 virtualenv 使用的是 python 解释器 2.7.3,将其替换为 2.7.6。

echo "Using " && python2.7 --version
mv myenv/bin/python myenv/bin/python.bak;
cp `which python2.7` myenv/bin/python

创建新的 virtualenv 时,它使用系统中更新的 python 二进制文件。因此,这解释了线程中接受的答案。

关于python - 导入错误 : No module named _io in ubuntu 14. 04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23176697/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com