Can't install packages in Windows 10

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I just reinstalled Python 3.6, but when I try to install packages, Windows returns errors. First I tried installing package BeautifulSoup from the Windows command prompt:

python -m pip install BeautifulSoup 

but this returns the following error:

Collecting BeautifulSoup   Using cached BeautifulSoup-3.2.1.tar.gz     Complete output from command python setup.py egg_info:     Traceback (most recent call last):       File "<string>", line 1, in <module>       File "C:\Users\Robert\AppData\Local\Temp\pip-build-iiyyxs2o\BeautifulSoup\setup.py", line 22         print "Unit tests have failed!"                                       ^     SyntaxError: Missing parentheses in call to 'print'      ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in C:\Users\Robert\AppData\Local\Temp\pip-build-iiyyxs2o\BeautifulSoup\ 

Then I tried installing package requests:

python -m pip install requests 

but this returns

C:\Program Files\Python36>python -m pip install requests Collecting requests   Using cached requests-2.18.4-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests)   Using cached certifi-2017.7.27.1-py2.py3-none-any.whl Collecting idna<2.7,>=2.5 (from requests)   Using cached idna-2.6-py2.py3-none-any.whl Collecting chardet<3.1.0,>=3.0.2 (from requests)   Using cached chardet-3.0.4-py2.py3-none-any.whl Collecting urllib3<1.23,>=1.21.1 (from requests)   Using cached urllib3-1.22-py2.py3-none-any.whl Installing collected packages: certifi, idna, chardet, urllib3, requests Exception: Traceback (most recent call last):   File "C:\Program Files\Python36\lib\site-packages\pip\basecommand.py", line 215, in main     status = self.run(options, args)   File "C:\Program Files\Python36\lib\site-packages\pip\commands\install.py", line 342, in run     prefix=options.prefix_path,   File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 784, in install     **kwargs   File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 851, in install     self.move_wheel_files(self.source_dir, root=root, prefix=prefix)   File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files     isolated=self.isolated,   File "C:\Program Files\Python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files     clobber(source, lib_dir, True)   File "C:\Program Files\Python36\lib\site-packages\pip\wheel.py", line 316, in clobber     ensure_dir(destdir)   File "C:\Program Files\Python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir     os.makedirs(path)   File "C:\Program Files\Python36\lib\os.py", line 220, in makedirs     mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 'C:\\Program Files\\Python36\\Lib\\site-packages\\certifi' 

What do I need to do so that pip successfully installs packages?

回答1:

BeautifulSoup is for Python 2 only. For Python 3 install beautifulsoup4:

pip install beautifulsoup4 

The second problem seems obvious: you don't have write-access to C:\\Program Files\\Python36\\Lib\\site-packages and subdirectories.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!