简体   繁体   中英

Installing nose using pip, but bash doesn't recognize command on mac

I'm trying to install nose on my computer for the Learn Python the Hard Way tutorial, but can't seem to get it to work. I'm using pip to install:

$ pip install nose

And I get back:

Requirement already satisfied (use --upgrade to upgrade): nose in /usr/local/lib/python2.7/site-packages
Cleaning up...

However, when I run the command nosetests, I get:

-bash: nosetests: command not found

I'm thinking there's something wrong with my PATH, but honestly I have no idea. Any help would be greatly appreciated!

我遇到这个问题,直到我用sudo设置鼻子:

sudo pip install nose

i had the same problem but this solved it.

  1. Install: nose2
  2. Then use: nose2 instead of nosetests to test program

Good Luck...!

I'm using OS X 10.11.1.

Do the following in the terminal:

  1. Move into directory ~/Python/2.7/site-packages/

  2. type sudo easy_install pip

  3. type sudo easy_install virtualenv

  4. type sudo easy_install nose

  5. type sudo easy_install distribute

  6. Follow the steps as instructed in the Learn Python The Hard Way book.

在OSX上,使用pip将nose 1.3安装的鼻子安装到/ usr / local / share / python / nosetests,默认情况下不在$ PATH中。

Sorry for resurrecting an old thread, but I just want to point out that no one has mentioned activating the virtual environment. People are asking "Are you in the virtual environment?" but user2778157 seems to be confused on exactly what that means. I would like to clarify this and think it may actually be the source of the problem. (Sorry for the pun on source).

When you use pip install , you aren't installing to your host's system, but into the virtual environment. When you create a virtual environment, it will have a folder bin with a file activate in it. In order to activate the virtual environment, you need to do source PATH/TO/ACTIVATE . While your virtual environment is activated, your system will check your virtual environment for the program before checking the host, and this is where your pip packages should be.

The reason you don't use sudo pip install is because this will get the super user (who doesn't have the environment activated) to install the package, which will go to your host.

However, when I run the command nosetests,

Of course, how you ran that command and from what directory might be important.

I'm thinking there's something wrong with my PATH, but honestly I have no idea.

If you do:

$ echo $PATH

...you will be able to see all the directories in your path. Of course, you can add any directory you want to your PATH.

However, I recently installed nose on my mac, and I installed by hand:

.../Downloads$ tar xfvz nose-1.3.0
.../Downlaods$ cd nose-1.3.0
.../nose-1.3.0$ sudo python setup.py install

...and nosetests installed here:

$ which nosetests
/Library/Frameworks/Python.framework/Versions/2.7/bin/nosetests

And there is a nose directory in my site-packages directory as per usual, as well. So on my mac, nosetests installed in a directory outside the site-packages directory. It's possible that only newer versions of nose install the nosetests command. You might want to try:

$ pip install --upgrade nose

Setting PATH variable for 'nosetests' is required. Please use this one on your Terminal:

alias nosetests='/Library/Frameworks/Python.framework/Versions/2.7/bin/nosetests'

Good luck!

pigging backing off of 7stud, you could do sudo find / -name nosetests and then append that to your PATH

(I'm sure that doing find off of / is a bit overkill, but I like that it goes over the entire OS)

你可以使用apt-get -y install python-nose重新apt-get -y install python-nose

I know this is an old thread but just in case someone else needs it:

I'm using OS X 10.9.3. After installing all of the packages 'cd' into the project directory as instructed in the book. Then type

sudo nosetests

Then you'll see what the 'learnpythonthehardway' author shows in the book and online.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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