无法导入python中的任何模块

无法导入python中的任何模块,python,python-2.7,pandas,pip,python-import,Python,Python 2.7,Pandas,Pip,Python Import,Python库在导入时出现错误。几乎所有库都出现相同的错误。对于简单的pip模块以及熊猫等,情况就是如此 1.皮普 $python Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pip Tracebac

Python库在导入时出现错误。几乎所有库都出现相同的错误。对于简单的pip模块以及熊猫等,情况就是如此

1.皮普

$python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2  
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 13, in <module>
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python2.7/dist-packages/pip/exceptions.py", line 6, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 3, in <module>
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/__init__.py", line 53, in <module>
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/packages/__init__.py", line 29, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/__init__.py", line 8, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 35, in <module>
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 14, in <module>
File "/usr/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random.py", line 2
hvsbiav
^
IndentationError: unexpected indent
$python
Python 2.7.12(默认值,2016年11月19日,06:48:10)
[GCC 5.4.0 20160609]关于linux2
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口pip
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/lib/python2.7/dist-packages/pip/_-init___;u.py”,第13行,在
从pip.exceptions导入InstallationError、CommandError、PiperError
文件“/usr/lib/python2.7/dist-packages/pip/exceptions.py”,第6行,在
来自pip.\u供应商。六个进口iteritems
文件“/usr/lib/python2.7/dist packages/pip/\u vendor/\uuuu init\uuuuuu.py”,第64行,在
卖方(“缓存控制”)
文件“/usr/lib/python2.7/dist packages/pip/\u vendor/\uuuu init\uuuuuuuu.py”,第36行,以vendored格式显示
__导入(modulename,globals(),locals(),level=0)
文件“/usr/share/python wheels/CacheControl-0.11.5-py2.py3 none any.whl/CacheControl/_init__.py”,第9行,在
文件“/usr/share/python wheels/CacheControl-0.11.5-py2.py3 none any.whl/CacheControl/wrapper.py”,第1行,在
文件“/usr/share/python wheels/CacheControl-0.11.5-py2.py3 none any.whl/CacheControl/adapter.py”,第3行,在
文件“/usr/share/python wheels/requests-2.9.1-py2.py3 none any.whl/requests/_init__.py”,第53行,在
文件“/usr/share/python wheels/requests-2.9.1-py2.py3 none any.whl/requests/packages/_init__.py”,第29行,在
文件“/usr/share/python wheels/urllib3-1.13.1-py2.py3 none any.whl/urllib3/__init___;.py”,第8行,在
文件“/usr/share/python wheels/urllib3-1.13.1-py2.py3 none any.whl/urllib3/connectionpool.py”,第35行,在
文件“/usr/share/python wheels/urllib3-1.13.1-py2.py3 none any.whl/urllib3/connection.py”,第14行,在
文件“/usr/lib/python2.7/httplib.py”,第80行,在
进口美托尔
文件“/usr/lib/python2.7/mimetools.py”,第6行,在
导入临时文件
文件“/usr/lib/python2.7/tempfile.py”,第35行,在
从随机导入随机为_随机
文件“random.py”,第2行
hvsbiav
^
缩进错误:意外缩进
请帮忙

::更新:


我知道这不是一个理想的方法,但我通过简单地从在线替换随机文件解决了这个问题,然后效果很好。

查看回溯,您的
random.py
文件中似乎有一个不正确的缩进。尝试查看该文件并将您的内容与之匹配

但是,如果问题仍然存在,您可以尝试使用以下命令强制重新安装Python包:

sudo pip install --upgrade --no-deps --force-reinstall <packagename>
sudo apt-get install --reinstall python2.7