Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

numpy - Can not execute python script or go to python shell

I can not run my Python script or even run command Python to go to python shell. What's wrong with my Python?

machine:project user$ python
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 62, in <module>
    import os
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 398, in <module>
    import UserDict
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 83, in <module>
    import _abcoll
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 11, in <module>
    from abc import ABCMeta, abstractmethod
  File "abc.py", line 2, in <module>
    import scipy.special
  File "/Library/Python/2.7/site-packages/scipy/__init__.py", line 70, in <module>
    from numpy import show_config as show_numpy_config
  File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 153, in <module>
    from . import add_newdocs
  File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 11, in <module>
    from . import numeric
  File "/Library/Python/2.7/site-packages/numpy/core/numeric.py", line 5, in <module>
    import collections
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/collections.py", line 6, in <module>
    __all__ += _abcoll.__all__
AttributeError: 'module' object has no attribute '__all__'

But anyway everything still looks fine if run Python outside my project directory.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have a local file called abc.py which is hiding the built-in abc module. Rename your file to something else.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...