1

首先,让我说我是 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
4

2 回答 2

3

您正在尝试在没有必要权限的情况下全局安装鼻子。

您可以使用sudo pip install nose,或者最好使用虚拟环境 ( https://virtualenv.readthedocs.org/en/latest/ ) 进行开发。有了这些,你可以在没有 root 权限的情况下安装和删除东西,你不能弄乱你的全局设置,你可以在你正在处理的不同项目中使用不同版本的库。

如果您尝试虚拟环境,还请查看virtualenvwrapper,这有助于保持它们的组织性。

于 2013-05-08T05:39:18.747 回答
3

您需要pip install nosesudo.

于 2013-05-08T05:35:20.780 回答