简体   繁体   English

安装鼻子测试-权限被拒绝

[英]Installing nosetests - permission denied

Trying to install nosetests as per the learnpythonthehardway tutorial, I'm having problems. 尝试按照learnpythonthehardway教程安装鼻子测试,我遇到了问题。 Any clues on what I should try next? 关于下一步应该尝试的任何线索?

$ easy_install nose
Searching for nose
Best match: nose 1.1.2
Processing nose-1.1.2-py2.6.egg
nose 1.1.2 is already the active version in easy-install.pth
Installing nosetests-2.6 script to /usr/local/bin
error: /usr/local/bin/nosetests-2.6: Permission denied`

One question about installing that I have: if I have something saved in a random location on my computer, can it be imported into a python script regardless of where it is? 关于安装的一个问题:如果我的计算机上的某个随机位置保存了某些内容,则无论它在哪里,都可以将其导入到python脚本中吗? So if I execute runthis.py that's in a folder called "projects", and I have from setup tools import setup as the first line of the program, does setup tools have to be anywhere in particular (such as the "projects" folder) for python to find it? 因此,如果我在名为“ projects”的文件夹中执行runthis.py,并且from setup tools import setup作为程序的第一行,则setup tools是否必须特别位于任何地方(例如“ projects”文件夹)为python找到它?

Are you able to use sudo ? 可以使用sudo吗?

If so, simply use sudo easy_install nose to install as root. 如果是这样,只需使用sudo easy_install nose安装为root。

If not, you'll need to install somewhere you can write to, not the default location which you don't have permission to modify. 如果没有,您将需要安装在可以写入的位置,而不是您无权修改的默认位置。 This can be done easily in the traditional way, or using virtualenv which can a bit trickier to get set up initially. 可以通过传统方式轻松完成此操作,也可以使用virtualenv进行设置,一开始设置起来可能会比较棘手。

As for the second question, no, python will only find things that are in directories found in sys.path , which is set to the contents of the PYTHONPATH environment variable plus the installed python's own library directories by default. 对于第二个问题,否,python只会在sys.path中找到的目录中找到东西,该目录设置为PYTHONPATH环境变量的内容以及默认情况下已安装的python自己的库目录。

It is often (highly!) advisable to set up your own "local" repository of packages, for whatever language system (be it Python or otherwise) that you are using. 通常(高度!)建议为您使用的任何语言系统(无论是Python还是其他语言)建立自己的“本地”软件包存储库。 Leave the "system installed" packages, whatever they might be, completely alone ... in case some uber-important system tool (the package-manager, anyone?) might also be using them and might be dependent on them. 不管它们是什么,都将“系统安装”软件包完全保留下来……以防某些超级重要的系统工具(软件包管理器,有人吗?)也可能正在使用它们,并可能依赖于它们。

The means of doing this vary from language to language, but they'll be documented somewhere all the same. 这样做的方法因语言而异,但是将在相同的地方进行记录。 You might even find that the "distro" that you're using has already anticipated this requirement and has set-aside some agreed upon location, eg "/usr/local/..." just for your own personal use. 您甚至可能会发现您正在使用的“发行版”已经预见到了这一要求,并且已经预留了一些商定的位置, 例如 “ / usr / local / ...”仅供您个人使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM