Reputation: 3974
I am getting following error while mere importing nose using import nose
:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
import nose
File "C:\Python32\Lib\site-packages\nose-master\nose\__init__.py", line 1, in <module>
from nose.core import collector, main, run, run_exit, runmodule
File "C:\Python32\Lib\site-packages\nose-master\nose\core.py", line 143
print "%s version %s" % (os.path.basename(sys.argv[0]), __version__)
I am new to python.
I have added path using sys.path.append("C:\\Python32\\Lib\\site-packages\\nose-master")
Upvotes: 0
Views: 2029
Reputation: 365587
The problem is that you haven't installed nose
properly.
Like most packages, nose
expects you to install it, not just use it out of the source in-place.
The official Python docs include Installing Python Modules. However, that document may be a bit over-complicated for novices, especially Windows users, and it doesn't mention some of the newer, simpler options. But briefly:
cd
to the source directory.C:\Python32\python.exe setup.py install
However, you will probably find it a lot easier to just automatically install things using pip
, or pre-made binary packages.
Having done this, nose
should end up in the right place in site-packages
so you don't need to do any sys.path
munging in your code, and you should also end up with the command-line scripts like nosetests
somewhere useful, like C:\Python32\Scripts\
.
The specific problem in this case is that, as part of the installation process, nose
figures out whether you're installing for Python 2.x or 3.x, and runs a tool called 2to3
to fix the code appropriately. Because you never did that step, you ended up with 2.x-specific code. As you guessed, it's the print
statement vs. print
function that bit you first—but if you got past that, there are dozens of other things that would fail similarly.
Upvotes: 1