簡體   English   中英

安裝BeautifulSoup時出錯

[英]Error while installing BeautifulSoup

我的問題是兩個方面。 我正在嘗試安裝BeautifulSoup,但遇到以下錯誤:

Rahul-MacBook-Air:~ rahul$ sudo easy_install pip
Password:
Searching for pip
Best match: pip 8.1.2
Processing pip-8.1.2-py2.7.egg
pip 8.1.2 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

Rahul-MacBook-Air:~ rahul$ pip install beautifulsoup4
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.5.1-py2-none-any.whl
Installing collected packages: beautifulsoup4
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 317, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/beautifulsoup4-4.5.1.dist-info'

有人可以告訴我我在做什么錯嗎?

我的下一個問題與上一個問題有關。 我已經安裝了Python 3.5.2

>>> print(sys.version)
3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
>>> 

但是在終端上,它顯示了一個不同的版本:

Rahul-MacBook-Air:~ rahul$ python -V
Python 2.7.10

因此,當我嘗試安裝BeautifulSoup時,它開始指向Python 2.7,我認為這是錯誤的。 它應該指向最新的Python版本,即3.5.2。

另外我已經在/usr/bin/python預裝了Python 2.7,在/usr/local/bin/python安裝了Python 3.5.2。 如何默認Python版本,以便每次打開終端時它都已指向Python 3.5.2

謝謝,拉胡爾

您在安裝BeautifulSoup時遇到了麻煩,因為您正在運行其命令的用戶沒有足夠的權限來訪問系統目錄。 嘗試使用sudo運行命令:

sudo pip install beautifulsoup4

接下來,您要說的是您已經安裝了Python 3.5.2,但是沒有顯示用於運行它的命令。 我敢肯定這件事情就像python3 (在任何情況下, 不能簡單地python ),是什么讓你想知道為什么python -V顯示不同的版本號? python命令運行另一個Python解釋器。

如果要為Python 3.5安裝任何軟件,則需要pip3而不是pip

您可以將python作為python3.5的別名(或符號鏈接),並且可能將python 2.7解釋python3.5命名為python2.7 ,如果尚未完成的話。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM