Python 不加载 _fileio 库
我遇到一个问题,Python没有加载动态C库_fileio。
~ $ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Could not open PYTHONSTARTUP
IOError: [Errno 2] No such file or directory: '/home/sven/.pythonrc'
>>> import io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/io.py", line 63, in <module>
import _fileio
ImportError: No module named _fileio
>>>
~ $ locate _fileio
/usr/lib/python2.6/lib-dynload/_fileio.so
~ $ echo $PYTHONPATH
/usr/lib/python2.6/
你好,Sven
2 个回答
1
看起来这是个环境设置的问题,主要是因为这一行:
IOError: [Errno 2] No such file or directory: '/home/sven/.pythonrc'
要解决这个问题,找到 .pythonrc
文件,并确保你的 .bashrc
文件里的 PYTHONSTARTUP
环境变量指向这个文件的位置。如果确认路径是正确的,可以试着直接使用硬编码的路径,比如 /home/sven/.pythonrc
,而不是用类似 ~/.pythonrc
这样的写法。
另外,如果我没记错的话,.pythonrc
应该是一个 *.py
文件,但这可能会根据不同的系统版本有所不同。
0
我在我的 zshrc 文件里有这一行
export PYTHONPATH=/usr/lib/python2.6
但是 Ubuntu 默认使用的是 Python 2.7.1
当我把上面那一行删掉后,错误信息就消失了。
抱歉,是我的错。