Unable to import a module into python

advertisements

I'm trying to use this python library in my website. Now, I've downloaded the sc2reader-0.6.5-py3.3.egg file and transferred the sc2reader folder in some random directory on my FTP account. I've also created files called test.py and test.php in the same directory. Test.php executes the test.py, and test.py imports the sc2reader library.

This is the code in the test.py:

import sys
import sc2reader
print 'Works'

And it doesn't run, if I remove the second line (import sc2reader), it runs just fine.

The directory structure looks like this:

/random_dir
L________/sc2reader
         L_____ __init__.py
         L______/other_stuff
L________test.py
L________test.php

Any help is much appreciated. :P


From the docs of sc2reader:

Install from the latest release on PyPI with pip:

pip install sc2reader

or easy_install:

easy_install sc2reader

The egg file you downloaded is meant to be installed using easy_install. You can do this by running:

easy_install sc2reader-0.6.5-py3.3.egg.

I would recommend just installing with pip under virtualenv. That way, when Python or a library you use is updated, your environment doesn't change with them and your application will continue to work.