无法执行python脚本或转到python shell [英] Can not execute python script or go to python shell

查看:105
本文介绍了无法执行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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆