'nosetests' not recognized on Windows afte

2019-03-20 08:45发布

问题:

I'm on exercise 46 of Learn Python the Hard Way, and I'm meant to install nose and run nosetests. I've installed nose already using pip, but when I run nosetests in the directory above the 'tests' folder, I get the error:

'nosetests' is not recognized as an internal or external command, operable program or batch file.

If it's relevant, I've already modified the PATH variable to include full path of Python27/Scripts and Python/Lib/site-package.

回答1:

If you are still having trouble after following Warren Weckesser's instructions try uninstalling and reinstalling.

Using pip: pip uninstall nose

I found this worked for me on Windows 8 64 bit



回答2:

I use Windows and I had the same problem.The LPTHW book is based on Linux OS and it's a bit difficult for windows users. When I typed nosetests, I got errors. Then I typed python -m nose , as per said by Spellstaker and it worked perfectly. I have noticed that in most cases we need to add 'python -m' at the beginning to make it work on Windows.



回答3:

You can also use python -m nose in PowerShell.

This worked for me in Windows 7, 32 bit.



回答4:

Command: python -m nose or py -m nose

Remember you should stay in the current virtual environment to run the nose if it is installed locally. Check the local environment name lpthw in the PowerShell after you activate the same.