pip install,pandas,selenium中的Deepcopy错误,无处不在

时间:2016-09-21 17:50:03

标签: python

我最近在运行python 2.7的Windows 2008 R2服务器上遇到深度复制错误。

即使是简单的pip安装-U selenium也会出现此错误

  Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\pip\__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
 File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
 File "c:\python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 71, in <module>
__import__('pip._vendor.packaging.requirements')
 File "c:\python27\lib\site-packages\pip\_vendor\packaging\requirements.py", line 9, in <module>
from pip._vendor.pyparsing import (
File "c:\python27\lib\site-packages\pip\_vendor\pyparsing.py", line 3462, in <module>
_reBracketExpr = Literal("[") + Optional("^").setResultsName("negate") + Group( OneOrMore( _charRange | _singleChar ) ).setResultsName("body") + "]"
File "c:\python27\lib\site-packages\pip\_vendor\pyparsing.py", line 884, in setResultsName
newself = self.copy()
File "c:\python27\lib\site-packages\pip\_vendor\pyparsing.py", line 858, in copy
cpy = copy.copy( self )
 AttributeError: 'module' object has no attribute 'copy'

当我在python shell中运行命令mydriver = webdriver.Firefox()时,我收到此错误

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py",line 51, in __init__
self.profile = firefox_profile or FirefoxProfile()
 File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 67, in __init__
self.default_preferences = copy.deepcopy(
AttributeError: 'module' object has no attribute 'deepcopy'

导入pandas时出现类似错误。

1 个答案:

答案 0 :(得分:2)

当你运行Python脚本的文件夹中存在copy.pycopy.pyc时,就会发生这种情况。因此,当您import copy实际导入工作目录中的copy.py时。请确保不要使用copy.py作为您的文件名。