我有一个问题,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/
问候斯文
最佳答案
似乎是一个环境问题,源于这一行:
IOError: [Errno 2] No such file or directory: '/home/sven/.pythonrc'
要解决此问题,请找到 .pythonrc
并确保 .bashrc
文件中的 PYTHONSTARTUP
环境变量指向此文件位置。如果它实际上是正确的,请尝试使用硬编码路径到 /home/sven/.pythonrc
而不是诸如 ~/.pythonrc
之类的路径。
此外,如果我没记错的话,.pythonrc
实际上应该是一个 *.py
文件,但这可能会因发行版而异。
关于Python 不加载 _fileio 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6778176/