我有一个问题,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并确保PYTHONSTARTUP文件中的.bashrc环境变量指向此文件位置。如果实际上是正确的,请尝试使用/home/sven/.pythonrc的硬编码路径,而不要使用~/.pythonrc之类的路径。

另外,如果我没记错的话,.pythonrc实际上应该是一个*.py文件,但是可能会有所不同,具体取决于发行版。

10-04 20:59