I installed Nose on a Mac OSX 10.10.5 with Python2.7.9 using easy_install. The installation appeared to be successful:
Collecting nose
Downloading nose-1.3.7-py2-none-any.whl (154kB)
100% |████████████████████████████████| 155kB 2.3MB/s
Installing collected packages: nose
Successfully installed nose-1.3.7
But now, when I try even basic stuff with nosetests on the command line, like nosetests -h or which nosetests I just get:
bash: nosetests: command not found
I have tried uninstalling, reinstalling using pip, tried installing with sudo and then running sudo nostests in the directories with tests scripts as other posts have suggested, but nothing seems to work.
The original purpose for installing was to use nose to run some basic tests with tests scripts I had written for these simple web.py apps. But nothing works, just keep getting the command not found response.
What's strange is that, when I open up the Python interpreter in Terminal, and do something like:
import nose
nose.main()
I get the expected result of:
.
----------------------------------------------------------------------
Ran 1 test in 0.135s
OK
So clearly it's installed....somewhere. Any suggestions for what the hell is going on here?
There are lots of error occurred when using pip install packages on Mac OS. So I recommend you install nose using easy_install.
$ pip uninstall nose
$ sudo easy_install nose
Then you can try nosetests now :)
I had this exact issue on OS X EI Captain with Python 2.7.10.
First I installed nose using pip:
$sudo pip install nose
which failed on the first attempt. Went through on the second attempt. But the nosetests command didn't work.
In order to fix this:
Step 1: Don't uninstall nose if it was installed already using pip as in my case.
Step 2:
$cd /usr/bin
$sudo easy_install nose
Above command finds the nosetests script (which was installed by pip earlier) & sets it under /usr/local/bin
Step 3: Try nosetests
$nosetests
----------------------------------------------------------------------
Ran 0 tests in 0.047s
OK
On UNIX-like systems like OS X, the script should be in /usr/local/bin. Make sure that directory is in the PATH environment variable in the shell that you use.
If not, you can also locate it using find, e.g:
find / -type f -name 'nosetests*' -perm +111 -print -quit
This means; search for a file whose name starts with nosetests, which has execute permissions set. Print the path name and stop.
I found that going to
Library/usr/bin
and running
sudo easy_install nose
it seems that sometimes it doesn't automatically install nose (and therefore nosetests functionality). Do the above lines, and you should be a-ok.
I wish i had a better explanation for why this happened, but i'm still pretty new, myself.
I had to use
Nosetest
or
python3 -m "nose"
Apparently this is the way Nosetest should be used in Python3. See also
How to make nosetests use python3
First, can you run 'python' from the command line? nosetests should be in that same directory:
rich bin $ which python
/home/rich/anaconda/bin/python
rich bin $ which nosetests
/home/rich/anaconda/bin/nosetests
It should also be in the downloaded nose package:
rich bin $ find /home/rich/anaconda -name nosetests
/home/rich/anaconda/pkgs/nose-1.3.3-py27_0/bin/nosetests
/home/rich/anaconda/pkgs/nose-1.3.7-py27_0/bin/nosetests
/home/rich/anaconda/bin/nosetests
From what I understand, everyone is moving to pytest - an actively-maintained testing framework.
It's not a solution to this problem, but it's likely the most-appropriate choice if you are still using nose.
I try to reinstall the pip, it doesn't work but lastly, when i use sudo ...it works
pip3 uninstall nose
sudo pip3 install nose
and
which nosetests
/usr/local/bin/nosetests
This can also happen if you were running nose within a virtual environment, and that virtual environment has been deactivated. If this is the case, reactivate with source bin/activate.
Related
I am trying to use venv for my project and it doesn't work correctly.
So first of all I am activating my venv and than use command "pip freeze" to check if there are no modules installed from my computer. And there is an output^
user#DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts
$ activate
(app) user#DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts
$ pip freeze
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
accessify==0.3.1
appdirs==1.4.3
attrs==19.3.0
backcall==0.1.0
beautifulsoup4==4.8.2
bleach==3.1.0
bs4==0.0.1
...
And that is incorrect because I have no modules installed in this venv. What could be the problem?
UPD:
Trying pip --version with venv:
(app) user#DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts $ pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future
version of pip. Please see github.com/pypa/pip/issues/5599 for advice on fixing the
underlying issue. To avoid this problem you can invoke Python with '-m pip' instead
of running pip directly. pip 20.0.2 from
C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pip (python 3.8)
Also I have founded another problem. For example, I have two python files in one directory:
- app/
- main.py
- conf.py
And when I am trying to import conf as module in main.py, I got the error:
ModuleNotFoundError: No module named 'conf'
Maybe the problem is with Windows? Becuase on the laptop with Windows I don't have any problems like that.
It seems that this problem is caused by two versions of pip, or a fail update attempt.
I suggest that you try following these instructions.
Alternatively try running where pip and pip --version inside and out side the virtual-env and look for differences.
I hope you'll figure this out, the github thread suggests the problem still doesn't have an obvious solution.
I haven't tried yet out of fear I'll mess up more than I'll fix but I don't know if I can use PYTHONPATH to fix my problem. I've installed python 2.7.10 and python 3.4.2 on my Macbookpro. Python2.7 doesn't have problems, only 3.4 does. I'm afraid if I use PYTHONPATH to fix python3, it will affect python2.
Anyway, I've run:
sudo pip install blah2
sudo pip3 install blah3
pip freeze | grep blah2
blah2=2.12345
pip3 freeze | grep blah3
blah3=3.12345
and I can see I've installed the respective modules for python2 and python3 as pip freeze has shown.
However, I keep getting errors when running scripts from cmd line for python 3.4 that say the module isn't found.
On further investigation using sys.path in my script, I can see python3 from cmd line is looking for modules at
/usr/local/lib/python3.4/site-packages
which doesn't have anything inside of it, whereas Idle for python 3.4 is looking at
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
which has tons of files in there.
I don't know why this got messed up in the first place or what I forgot to do to mess it up like this but how do I tell python 3.4 to look at the /Library location for modules?
The funny thing is both python2 and 3 were installed from tar/gzip files. I ran both using the
configure; make ;make install
command but for some reason python2 is fine but python3 isn't.
This may mean the pip3 is installing to that different path.
Take a look at pip3 script and see where it is putting the package files. In my case the first line of it looks like this:
#!/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
Look if this is the path to the correct python3 binary. If it's not, you have two options: change this first line of pip3 to the path of your desired python3 binary, or just forget about it, use the pip directly with python3 command:
python3 -m pip install blah3
This should use the appropriate path when installing the package.
I have both Python 2.7 and 3.3 installed on a Mac. I'm trying to get Pytest to run my tests under Python 3.3.
When I run python3 –m py.test it halts, looking for the libs under the 3.3 path.
When I run pip install –U pytest it installs to the 2.7 path.
I've seen the write-ups for Virtualenv, but I'm not ready to go there yet.
Is there another way?
Take a look at the tox project. It helps you to test your code under different python versions and interpreters.
Example tox.ini config for your case:
[tox]
envlist = py27,py33
[testenv]
deps = pytest
commands = py.test
It's not a silver bullet but it will definitely help to automate your tedious test activities.
Apart from the genscript option the normal way to go about this is to intall py.test into the python3.3 interpreter's environment. The problem you have is that the pip you invoke is also a py27 version, so it will install into py27.
So you can start with installing pip into py33 (usually under the alias pip3) and then invoking that pip or you can simply install py and pytest in the py33 environment the old fashioned way: download the packages and run python3.3 setup.py install --user.
You will then still want to make sure you can invoke the correct version of py.test however, either making sure you can call py.test and py.test3 using aliases or so. Or simply by using pythonX.Y -m pytest.
I recently installed python3 only to realize that mysql-python as well as many other modules were not well supported with it yet. So I changed the path in my bashrc file to point to an installation of python 2.7. The problem is that when I installed python 3 I also installed distribute and pip along with it. I removed the pip and distribute files from the python3 bin directory and installed setuptools and pip using python 2.7 however now when I use the pip command to install django and mysql-python, I get a bash error python331/bin/pip No such file or directory. It's still looking for pip in the python3 install. How can I remedy this?
Thanks
...I get a bash error python331/bin/pip No such file or directory.
It's still looking for pip in the python3 install. How can I remedy
this?
bash, by default, hashes the locations of commands to avoid searching $PATH each time, so if, when you execute...
$ type pip
...you get something like...
pip is hashed (python331/bin/pip)
...you just need to clear the hash table for bash with...
$ hash -r
...then it'll pick up the version in Python 2.7 the next time you try to run pip.
Fixed it.
Renamed the directory of where the python3 was installed, bash automatically looks for the next available python install python 2.7
I'm trying to install the following as per the learnpythonthehardway tutorial:
pip from http://pypi.python.org/pypi/pip
distribute from http://pypi.python.org/pypi/distribute
nose from http://pypi.python.org/pypi/nose/
virtualenv from http://pypi.python.org/pypi/virtualenv
I've visited these links and clicked the download button; each file is in my downloads folder now, and I unarchive/unzipped them- not sure what this means but it seemed required. Are they "installed"? If not, what does it mean to really install them? I've tried typing nosetests in the terminal (as the book says you should), as well as tried easy_install but that doesn't seem to work. It appears my understanding is limited in a number of ways here.
I get the following -bash: nosetests: command not found, but am trying to get:
nosetests . ---------------------------------------------------------------------- Ran 1 test in 0.007s
OK
This works on mac, it may work on linux
1)Open terminal (Be prepared to enter your password)
2)Type: sudo easy_install pip
3)Type: sudo pip install distribute
4)Type: sudo pip install nose
5)Type: sudo pip install virtualenv
Hope that helps, cheers!
They are not yet installed.
Each has its own vagaries about how exactly the install process works and in fact some of those packages will include the other packages with them. I.e.
"If you use virtualenv, a copy of pip will be automatically be
installed in each virtual environment you create."
http://pypi.python.org/pypi/pip
As a relatively new python user myself, (and having gone thru a similar process not long ago) I am eagerly awaiting the more complete answers that come back for this one.
Find out where the nosetests script is. On OSX:
/usr/local/share/nosetests
Execute directly, or set up a bash alias, perhaps in .bash_profile:
alias nosetests='/usr/local/share/python/nosetests'
alias nosetests3='/usr/local/share/python3/nosetests'
You were on the right track, but the package is actually called "nose". The documentation for nose (nosetests is the script) can be found here:
https://nose.readthedocs.org/en/latest/
The short answer is that you have 2 basic options: easy_install or pip. Install using setuptools/distribute: easy_install nose. Install using pip: pip install nose
Install Python 2.7 and after just do this (only on Windows - Windows PowerShell):
Setup PATH env:
C:\Python27\;C:\Python27\Scripts\", "User"
pip is already installed
3.
.\pip install distribute
4.
.\pip install nose
5.
.\pip install virtualenv