2017-05-29 39 views
0

使用pip install tornado在Mac上出現錯誤:使用`PIP在Mac上安裝tornado`得到錯誤:權限被拒絕:「/Library/Python/2.7/site-packages/singledispatch.py​​

aircraftdeMacBook-Pro:~ ldl$ pip install tornado 
Collecting tornado 
    Downloading tornado-4.5.1.tar.gz (483kB) 
    100% |████████████████████████████████| 491kB 565kB/s 
Collecting singledispatch (from tornado) 
    Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl 
Collecting certifi (from tornado) 
    Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB) 
    100% |████████████████████████████████| 378kB 565kB/s 
Collecting backports_abc>=0.4 (from tornado) 
    Downloading backports_abc-0.5-py2.py3-none-any.whl 
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado) 
Installing collected packages: singledispatch, certifi, backports-abc, tornado 
Exception: 
Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main 
    status = self.run(options, args) 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run 
    prefix=options.prefix_path, 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install 
    **kwargs 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install 
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix) 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files 
    isolated=self.isolated, 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files 
    clobber(source, lib_dir, True) 
    File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 323, in clobber 
    shutil.copyfile(srcfile, destfile) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile 
    with open(dst, 'wb') as fdst: 
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/singledispatch.py' 

回答

0

鬥爭後,我用sudo pip install tornado解決了它。

Collecting tornado 
    Downloading tornado-4.5.1.tar.gz (483kB) 
    100% |████████████████████████████████| 491kB 557kB/s 
Collecting singledispatch (from tornado) 
    Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl 
Collecting certifi (from tornado) 
    Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB) 
    100% |████████████████████████████████| 378kB 641kB/s 
Collecting backports_abc>=0.4 (from tornado) 
    Downloading backports_abc-0.5-py2.py3-none-any.whl 
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado) 
Installing collected packages: singledispatch, certifi, backports-abc, tornado 
    Running setup.py install for tornado ... done 
Successfully installed backports-abc-0.5 certifi-2017.4.17 singledispatch-3.4.0.3 tornado-4.5.1 
1

一般來說,當指示說:時間

To install package123 run pip install package123

99%,它的假定包正在安裝在Python虛擬環境(通過virtualenvvenv)。這就是說,你應該在虛擬環境中安裝Tornado,並避免sudo pip install tornado。如果您使用sudo而不是第三方模塊對系統軟件包造成污染,則不會發生任何問題。