我遇到了一个我无法理解的奇怪错误。
在Python 2.7上,我使用MacPorts安装了py27-networkx软件包。当我尝试import networkx as nx
时,我收到以下错误。我的network.py
文件中唯一的一行是导入文件。
有关如何调试此问题的任何想法可以解决正在发生的事情吗?
Traceback (most recent call last):
File "network.py", line 1, in <module>
import networkx
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/__init__.py", line 43, in <module>
from networkx import release
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/release.py", line 45, in <module>
import subprocess
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
更新
跑几片帮助诊断。希望它能帮助某些人为我提供一些见解和解决方案。
which python
给了我/opt/local/bin/python
(我有标准的Mac OS X python,但我使用的是MacPorts安装的python2.7版本)import networkx
不会产生错误答案 0 :(得分:-1)
我也遇到了此错误,我通过使用python27
升级macports
来解决此问题。
将macports更新为最新版本:
sudo port selfupdate
列出过时的软件包(当我收到导入错误时,python27已经过时了):
sudo port outdated
更新过时的软件包:
sudo port upgrade outdated