2017-05-31 76 views
0

我無法在Mac OS X 10.11.6上使用nsetools無法在Mac OS X上使用nsetools 10.11.9

sudo pip install nsetools 
Password: 
The directory '/Users/debraj/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
The directory '/Users/debraj/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
Collecting nsetools 
Downloading nsetools-1.0.5.tar.gz 
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from nsetools) 
Installing collected packages: nsetools 
Running setup.py install for nsetools ... done 
Successfully installed nsetools-1.0.5 

我試着安裝nsetools而不是超級用戶。但它拋出下面的錯誤: -

pip install nsetools 
Collecting nsetools 
    Downloading nsetools-1.0.5.tar.gz 
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from nsetools) 
Installing collected packages: nsetools 
    Running setup.py install for nsetools ... error 
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/pip-build-nEc2HK/nsetools/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/pip-gh3BsV-record/install-record.txt --single-version-externally-managed --compile: 
    running install 
    running build 
    running build_py 
    creating build 
    creating build/lib 
    creating build/lib/nsetools 
    copying nsetools/__init__.py -> build/lib/nsetools 
    copying nsetools/bases.py -> build/lib/nsetools 
    copying nsetools/nse.py -> build/lib/nsetools 
    copying nsetools/utils.py -> build/lib/nsetools 
    running install_lib 
    creating /Library/Python/2.7/site-packages/nsetools 
    error: could not create '/Library/Python/2.7/site-packages/nsetools': Permission denied 

    ---------------------------------------- 
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/pip-build-nEc2HK/nsetools/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/pip-gh3BsV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/pip-build-nEc2HK/nsetools/ 

在嘗試使用nsetools我收到以下錯誤: -

python 
Python 2.7.11 (default, Jan 22 2016, 16:30:50) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from nsetools import Nse 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/nsetools/__init__.py", line 25, in <module> 
    from .nse import Nse 
    File "/Library/Python/2.7/site-packages/nsetools/nse.py", line 26, in <module> 
    import six 
ImportError: No module named six 

即使我已經安裝了six: -

sudo -H pip install six 
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 

有人能告訴我發生了什麼問題嗎?

+0

爲什麼將軟件包安裝爲超級用戶? – errata

+0

我得到錯誤'錯誤:無法創建'/Library/Python/2.7/site-packages/nsetools':權限被拒絕。 – tuk

回答

1

我強烈建議您不要使用sudo安裝pip軟件包,而是閱讀關於使用Python的虛擬環境,例如virtualenvpyenv。沒有虛擬環境,你會經常面對錯誤,比如你提到的錯誤。

這應該可以幫助您設置虛擬環境:

$ pip install virtualenv 
$ virtualenv your_virtualenv_name 
$ source your_virtualenv_name/bin/activate 
(your_virtualenv_name) $ pip install nsetools 

this article,以獲取有關虛擬環境,其目的和用途的想法。

+0

我試圖以正常用戶的身份安裝'nsetools'時,得到的錯誤更新了這個問題。如果我嘗試通過運行'sudo python'來導入'nsetools',同樣的錯誤。如果我沒有'sudo'的話'pip安裝six',它會說'Requirement already satisfied:six in/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' – tuk

+0

更新了我的答案...不要使用sudo來安裝pip包! :)相反,找到一種方法來正確安裝它們作爲單個用戶。虛擬環境應該解決與這類問題有關的所有問題。 – errata

+0

因爲我已經安裝了。現在還在執行'pip install nsetools',顯示'Requirement is already satisfied'。你能告訴我如何使用'nsetools'嗎? – tuk