本文介绍了无法执行python脚本或进入python shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法运行我的 Python 脚本,甚至无法运行 Python 命令来进入 Python shell.我的 Python 有什么问题?
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__'
但无论如何,如果在我的项目目录之外运行 Python,一切看起来仍然很好.
But anyway everything still looks fine if run Python outside my project directory.
推荐答案
您有一个名为 abc.py
的本地文件,它隐藏了内置的 abc
模块.将您的文件重命名为其他名称.
You have a local file called abc.py
which is hiding the built-in abc
module. Rename your file to something else.
这篇关于无法执行python脚本或进入python shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!