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

10

35

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!

Harte answered 14/9, 2013 at 0:11 Comment(4)
Are you inside a virtualenv ?Senter
I tried setting up a virtual environment using virtualenv ENV, but my bash says the command is also not found (similar response to when I try to use nosetests)Harte
have you tried uninstalling/reinstalling nose?Senter
Was having the same issue. Uninstalling/reinstalling nose fixed it. I can now just type nosetests in a terminal and it runs nose.Pentagrid
S
14

I got this problem until I setup nose with sudo:

sudo pip install nose
Sober answered 8/11, 2013 at 4:24 Comment(2)
Don't use sudo, use a virtualenv.Voccola
For those with pip3: sudo pip3 install noseMcgaw
E
13

i had the same problem but this solved it.

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

Good Luck...!

Erastatus answered 30/9, 2016 at 15:27 Comment(0)
P
6

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.

Portend answered 19/11, 2015 at 20:28 Comment(0)
T
2

On OSX, using pip to install nose 1.3 installed nose to /usr/local/share/python/nosetests which isn't in the $PATH by default.

Trisa answered 12/2, 2014 at 0:23 Comment(0)
A
2

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.

Aspectual answered 28/7, 2017 at 14:38 Comment(0)
M
1

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
Mersey answered 14/9, 2013 at 3:18 Comment(3)
I tried upgrading nose and it said that my nose was already up to date. when I type $echo $PATH I get: /Users/zubinteherani/.rvm/gems/ruby-1.9.3-p392/bin:/Users/zubinteherani/.rvm/gems/ruby-1.9.3-p392@global/bin:/Users/zubinteherani/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/zubinteherani/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Applications/Postgres.app/Contents/MacOS/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/lib/python2.7/site-packages:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbinHarte
I would try unistalling: pip uninstall nose, and reinstalling by hand, as I showed above. Download nose-1.3.0.tar.gz here: pypi.python.org/pypi/nose/1.3.0 After downloading and before installing, do this: ~/Downloads$ md5 nose-1.3.0.tar.gz Then click on the md5 link lower down on the download page, and copy and paste the md5 into Terminal(on the line underneath the displayed md5). Add enough spaces to make the md5's line up, and then compare. If they are the same, install the module.Mersey
An option is of course to add the /Library... to your path, with the downside of it being dependent on the Python version (...Versions/x.y/bin)Abernon
G
1

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!

Gunshot answered 4/2, 2017 at 8:54 Comment(0)
P
0

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)

Paz answered 14/9, 2013 at 3:38 Comment(0)
M
-1

You can reinstall using apt-get -y install python-nose.

Malaysia answered 30/4, 2016 at 13:41 Comment(0)
V
-2

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.

Voccola answered 14/6, 2014 at 16:45 Comment(1)
sudo = bad. Use a virtualenv.Voccola

© 2022 - 2024 — McMap. All rights reserved.