networkx ImportError:无法导入名称_distributor_init

时间:2019-02-26 21:48:36

标签: python networking pip networkx importerror

我试图在程序中使用networkx库。它运行良好,没有任何投诉。但是,尽管我没有对该程序进行任何更改,但是现在突然开始抱怨了。很奇怪。我试图重新安装networkx和numpy,但是系统只是说他们很满意。

Traceback (most recent call last):
  File "degree_discount.py", line 4, in <module>
    import networkx as nx 
  File "/home/jessy/venv/local/lib/python2.7/site-packages/networkx/__init__.py", line 98, in <module>
    import networkx.utils
  File "/home/jessy/venv/local/lib/python2.7/site-packages/networkx/utils/__init__.py", line 3, in <module>
    from networkx.utils.random_sequence import *
  File "/home/jessy/venv/local/lib/python2.7/site-packages/networkx/utils/random_sequence.py", line 16, in <module>
    import random
  File "/home/jessy/random.py", line 9, in <module>
    import numpy as np
  File "/home/jessy/venv/local/lib/python2.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import _distributor_init
ImportError: cannot import name _distributor_init

1 个答案:

答案 0 :(得分:0)

我知道了。我创建了一个名为“ random.py”的python文件。而且我在degree_discount.py中输入了“ import random”,所以我猜想python很困惑。