我使用的是Python 3.6,并使用pip install beautifulsoup4安装了beautifulsoup4。但是如果我在Python3环境中输入bs4 import BeautifulSoup,我会得到以下Trackback。我已经更新了beautifulsoup和html5作为一些类似的帖子建议,但是没有解决问题。
{'results': [], 'status': 'ZERO_RESULTS'}
AttributeError: module 'copy' has no attribute 'deepcopy'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "part.py", line 1, in <module>
from bs4 import BeautifulSoup as bs
File "/anaconda/lib/python3.6/site-packages/bs4/__init__.py", line 35, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/anaconda/lib/python3.6/site-packages/bs4/builder/__init__.py", line 323, in <module>
from . import _html5lib
File "/anaconda/lib/python3.6/site-packages/bs4/builder/_html5lib.py", line 20, in <module>
import html5lib
File "/anaconda/lib/python3.6/site-packages/html5lib/__init__.py", line 16, in <module>
from .html5parser import HTMLParser, parse, parseFragment
File "/anaconda/lib/python3.6/site-packages/html5lib/html5parser.py", line 6, in <module>
from . import inputstream
File "/anaconda/lib/python3.6/site-packages/html5lib/inputstream.py", line 10, in <module>
from . import utils
File "/anaconda/lib/python3.6/site-packages/html5lib/utils.py", line 8, in <module>
import xml.etree.cElementTree as default_etree
File "/anaconda/lib/python3.6/xml/etree/cElementTree.py", line 3, in <module>
from xml.etree.ElementTree import *
File "/anaconda/lib/python3.6/xml/etree/ElementTree.py", line 1654, in <module>
from _elementtree import *
SystemError: <built-in function __import__> returned a result with an error set
答案 0 :(得分:0)
我认为一个自定义模块可能是您编写的名为 copy.py
的东西在 python 的导入路径中,因此当 bs4
尝试使用 copy.deepcopy
中的 stdlib
时,它找不到。
从口译员那里,做:
import copy
然后:
copy.__file__.
如果它不是 Python 的 lib 文件夹,那就是你的问题!