首先,让我说我是Unix命令行的新手,所以请原谅我,如果有什么听起来很幼稚。我在我的机器上安装了pip,我正试图用它来安装鼻子。我的下载文件夹中有一个鼻子zip文件,我正在尝试将其安装到我的sitepackages目录中,因此我可以开始使用它进行单元测试。在终端,我输入了pip install nose并得到了你在下面看到的内容。任何想法在这里发生了什么?我是否需要使用sudo或者需要将鼻子zip文件放在另一个目录中才能被pip访问?...
Downloading/unpacking nose
Downloading nose-1.3.0.tar.gz (404kB): 404kB downloaded
Running setup.py egg_info for package nose
no previously-included directories found matching 'doc/.build'
Installing collected packages: nose
Running setup.py install for nose
error: could not create '/Library/Python/2.7/site-packages/nose': Permission denied
Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/var/folders/yy/4vm2zy7j5_s32zv4rwdhn5500000gn/T/pip-build-mikaschiller/nose/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/yy/4vm2zy7j5_s32zv4rwdhn5500000gn/T/pip-YKue2u-record/install-record.txt --single-version-externally-managed:
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/nose
copying nose/__init__.py -> build/lib/nose
copying nose/__main__.py -> build/lib/nose
copying nose/case.py -> build/lib/nose
copying nose/commands.py -> build/lib/nose
copying nose/config.py -> build/lib/nose
copying nose/core.py -> build/lib/nose
copying nose/exc.py -> build/lib/nose
copying nose/failure.py -> build/lib/nose
copying nose/importer.py -> build/lib/nose
copying nose/inspector.py -> build/lib/nose
copying nose/loader.py -> build/lib/nose
copying nose/proxy.py -> build/lib/nose
copying nose/pyversion.py -> build/lib/nose
copying nose/result.py -> build/lib/nose
copying nose/selector.py -> build/lib/nose
copying nose/suite.py -> build/lib/nose
copying nose/twistedtools.py -> build/lib/nose
copying nose/util.py -> build/lib/nose
creating build/lib/nose/ext
copying nose/ext/__init__.py -> build/lib/nose/ext
copying nose/ext/dtcompat.py -> build/lib/nose/ext
creating build/lib/nose/plugins
copying nose/plugins/__init__.py -> build/lib/nose/plugins
copying nose/plugins/allmodules.py -> build/lib/nose/plugins
copying nose/plugins/attrib.py -> build/lib/nose/plugins
copying nose/plugins/base.py -> build/lib/nose/plugins
copying nose/plugins/builtin.py -> build/lib/nose/plugins
copying nose/plugins/capture.py -> build/lib/nose/plugins
copying nose/plugins/collect.py -> build/lib/nose/plugins
copying nose/plugins/cover.py -> build/lib/nose/plugins
copying nose/plugins/debug.py -> build/lib/nose/plugins
copying nose/plugins/deprecated.py -> build/lib/nose/plugins
copying nose/plugins/doctests.py -> build/lib/nose/plugins
copying nose/plugins/errorclass.py -> build/lib/nose/plugins
copying nose/plugins/failuredetail.py -> build/lib/nose/plugins
copying nose/plugins/isolate.py -> build/lib/nose/plugins
copying nose/plugins/logcapture.py -> build/lib/nose/plugins
copying nose/plugins/manager.py -> build/lib/nose/plugins
copying nose/plugins/multiprocess.py -> build/lib/nose/plugins
copying nose/plugins/plugintest.py -> build/lib/nose/plugins
copying nose/plugins/prof.py -> build/lib/nose/plugins
copying nose/plugins/skip.py -> build/lib/nose/plugins
copying nose/plugins/testid.py -> build/lib/nose/plugins
copying nose/plugins/xunit.py -> build/lib/nose/plugins
creating build/lib/nose/sphinx
copying nose/sphinx/__init__.py -> build/lib/nose/sphinx
copying nose/sphinx/pluginopts.py -> build/lib/nose/sphinx
creating build/lib/nose/tools
copying nose/tools/__init__.py -> build/lib/nose/tools
copying nose/tools/nontrivial.py -> build/lib/nose/tools
copying nose/tools/trivial.py -> build/lib/nose/tools
copying nose/usage.txt -> build/lib/nose
running install_lib
creating /Library/Python/2.7/site-packages/nose
error: could not create '/Library/Python/2.7/site-packages/nose': Permission denied
答案 0 :(得分:3)
您需要在pip install nose
前加sudo
。
答案 1 :(得分:3)
您正试图在没有必要权限的情况下全局安装鼻子。
您可以使用sudo pip install nose
,或者最好使用虚拟环境(https://virtualenv.readthedocs.org/en/latest/)进行开发。有了这些,你可以安装和删除没有root权限的东西,你不会搞乱你的全局设置,你可以在你正在使用的不同项目中使用不同版本的库。
如果您尝试使用虚拟环境,请查看virtualenvwrapper,这有助于保持虚拟环境的有序性。