Spencer Ruport
Spencer Ruport

Reputation: 35117

Can't import installed package

I'm having a bit of trouble getting my setup.py file to work correctly. I'm able to run the install command and everything appears to be working. I see all the appropriate files being copied to various locations and there aren't any error messages but when I actually try to import the package from the python command line I get errors saying it doesn't exist.

Python install output Larger picture

Can anyone suggest what I'm doing wrong here?

Upvotes: 1

Views: 1079

Answers (2)

andrewgrz
andrewgrz

Reputation: 423

Assuming that's all the files to compiled in the picture, here is why all you tries failed.

1) You do not have a file named passport.phaseI. Imports must be mapped to a file.

2) Assuming you mean to import the Passport class in the passport/phase/passport file, you need to call it like: from passport.phase.passport import Passport

3) See number 1. You do not have a file named passport, but you do have a dir.

I think the code from number two is going to help you the best.

Edit: One more note: remember your __init__.py files in each folder.

Hope this helps!

Upvotes: 0

Kyle Hannon
Kyle Hannon

Reputation: 2249

Make sure you cd out of the install directory, otherwise you'll get weird behaviour. Also, if you run

import sys
print sys.path

Make sure the module was installed to a location that is on your python path

Upvotes: 1

Related Questions