gpt4 book ai didi

python - 导入错误: cannot import name 'main' when trying to download any python library

转载 作者:行者123 更新时间:2023-12-01 02:07:56 28 4
gpt4 key购买 nike

我已经能够正常下载 python 库一段时间了,但是发生了这种情况,我已经尝试了所有解决方案,但我认为这是针对我的情况的

我试图下载漂亮的汤,收到一个错误,说它无法正确加载“egginfo.py”或类似的内容,我发现可以通过升级 setuptools 来修复该错误。我这样做了并得到了这个:

D:\Python3_64\Scripts>pip install beautifulsoup
Traceback (most recent call last):
File "d:\python3_64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python3_64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python3_64\Scripts\pip.exe\__main__.py", line 5, in <module>

导入错误:无法导入名称“main”

使用简易安装:

D:\Python3_64\Scripts>easy_install beautifulsoup
Searching for beautifulsoup
Reading https://pypi.python.org/simple/beautifulsoup/
Downloading

https://pypi.python.org/packages/1e/ee/295988deca1a5a7accd783d0dfe14524867e31abb

05b6c0eeceee49c759d/BeautifulSoup-
3.2.1.tar.gz#md5=44656527ef3ac9874ac4d1c9f35f70ee
Best match: BeautifulSoup 3.2.1
Processing BeautifulSoup-3.2.1.tar.gz
Writing C:\Users\Owner\AppData\Local\Temp\easy_install-
iwb6x4a5\BeautifulSoup-3.2.1\setup.cfg
Running BeautifulSoup-3.2.1\setup.py -q bdist_egg --dist-dir
C:\Users\Owner\AppData\Local\Temp\easy_install-iwb6x4a5\BeautifulSoup-
3.2.1\egg-dist-tmp-rtwdsovx
Traceback (most recent call last):
File "d:\python3_64\lib\site-packages\setuptools\sandbox.py", line 154, in
save_modules
yield saved
File "d:\python3_64\lib\site-packages\setuptools\sandbox.py", line 195, in
setup_context
yield
File "d:\python3_64\lib\site-packages\setuptools\sandbox.py", line 250, in
run_setup
_execfile(setup_script, ns)
File "d:\python3_64\lib\site-packages\setuptools\sandbox.py", line 44, in
_execfile
code = compile(script, filename, 'exec')
File "C:\Users\Owner\AppData\Local\Temp\easy_install-
iwb6x4a5\BeautifulSoup-3.2.1\setup.py", line 22
print "Unit tests have failed!"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(int
"Unit tests have failed!")?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\python3_64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python3_64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python3_64\Scripts\easy_install.exe\__main__.py", line 9, in
<module>
File "d:\python3_64\lib\site-packages\setuptools\command\easy_install.py",
line 2312, in main
**kw
File "d:\python3_64\lib\site-packages\setuptools\__init__.py", line 129,
in setup
return distutils.core.setup(**attrs)
File "d:\python3_64\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "d:\python3_64\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "d:\python3_64\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "d:\python3_64\lib\site-packages\setuptools\command\easy_install.py",
line 412, in run
self.easy_install(spec, not self.no_deps)
File "d:\python3_64\lib\site-packages\setuptools\command\easy_install.py",
line 673, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "d:\python3_64\lib\site-packages\setuptools\command\easy_install.py",
line 699, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "d:\python3_64\lib\site-packages\setuptools\command\easy_install.py",
line 884, in install_eggs

因此,我无法再下载任何类型的 Python 库。

我已经尝试过:

-删除旧版本的 python

-升级安装工具

-使用 pip3

-使用 --user 标志安装

-运行提升的提示符并尝试安装

-使用easyinstall

-卸载并重新安装python

感谢所有帮助。

最佳答案

bs4 适用于 python3,BeautifulSoup 适用于 python2。您正在尝试安装错误的软件包。做

pip install bs4

关于python - 导入错误: cannot import name 'main' when trying to download any python library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48884253/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com