我以某种方式搞砸了我的python并且没有想法如何修复它。我使用的是Python 2.7.6。在Windows计算机上。基本上连接到xml的任何东西都停止了工作。含义:它之前工作正常,然后控制台崩溃了,现在我得到了描述的错误。
写作时
pip install numpy
在控制台中我收到以下错误:
Traceback (most recent call last):
File "C:\Python27\Scripts\pip-script.py", line 9, in <module>
load_entry_point('pip==1.5.2', 'console_scripts', 'pip')()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 351, in load_entry
_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2363, in load_entr
y_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "C:\Python27\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python27\lib\site-packages\pip\vcs\subversion.py", line 4, in <module
>
from pip.index import Link
File "C:\Python27\lib\site-packages\pip\index.py", line 18, in <module>
import html5lib
File "C:\Python27\lib\site-packages\html5lib\__init__.py", line 16, in <module
>
from .html5parser import HTMLParser, parse, parseFragment
File "C:\Python27\lib\site-packages\html5lib\html5parser.py", line 6, in <modu
le>
from . import inputstream
File "C:\Python27\lib\site-packages\html5lib\inputstream.py", line 10, in <mod
ule>
from . import utils
File "C:\Python27\lib\site-packages\html5lib\utils.py", line 8, in <module>
import xml.etree.ElementTree as default_etree
ImportError: No module named etree.ElementTree
到目前为止我做了什么:我试图重新安装xml包(在论坛中提出)。我还安装了各种环境的Anaconda。在那里,当我想使用像openpyxl这样的软件包时会出现问题,这会给我一个类似的错误信息:
Traceback (most recent call last):
File "HU_calc.py", line 1, in <module>
import openpyxl as px
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\__init__.py", line 29
, in <module>
from openpyxl.workbook import Workbook
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\workbook\__init__.py"
, line 5, in <module>
from .workbook import Workbook
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\workbook\workbook.py"
, line 7, in <module>
from openpyxl.worksheet import Worksheet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\worksheet\__init__.py
", line 4, in <module>
from .worksheet import Worksheet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\worksheet\worksheet.p
y", line 35, in <module>
from openpyxl.cell import Cell
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\cell\__init__.py", li
ne 4, in <module>
from .cell import Cell, WriteOnlyCell
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\cell\cell.py", line 4
5, in <module>
from openpyxl.styles import numbers, is_date_format
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\styles\__init__.py",
line 5, in <module>
from .alignment import Alignment
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\styles\alignment.py",
line 6, in <module>
from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\descriptors\__init__.
py", line 5, in <module>
from .sequence import Sequence
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\descriptors\sequence.
py", line 5, in <module>
from openpyxl.xml.functions import Element
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\xml\functions.py", li
ne 28, in <module>
from xml.etree.cElementTree import iterparse
ImportError: No module named etree.cElementTree
这对我来说尤其令人困惑,因为我认为Anaconda会创建一个与Windows完全隔离的python环境。我觉得我错过了一些非常明显的东西。如果我的问题中有任何遗漏/不清楚,我会尽快解决。
我非常感谢你的每一条建议。
答案 0 :(得分:1)
看起来你有一个名为xml.py
的python脚本。重命名它,它应该工作。