Reputation: 2451
I'm very new to Python and web development. I created a Python project and now I want to import an external library.
I want to import the apans-client
library, and this is what I’ve done:
Install the package on the command line:
$ cd apns-client-0.2.1
$ /Users/myuser/env/bin/python setup.py install
The installation runs and seems to complete successfully:
running install
running bdist_egg
running egg_info
writing requirements to apns_client.egg-info/requires.txt
..
..
..
Installed /Users/myuser/env/lib/python2.7/site-packages/pycparser-2.10-py2.7.egg
Finished processing dependencies for apns-client==0.2.1
Here env
is a virtualenv folder where my project is location.
But if I add import apnsclient
to one of my scripts and try to run it, then I get an error:
No module named apnsclient.
What am I missing?
I use PyCharm, and the Project Interpreter is pointing to a different Python installation:
/Library/Framework/Python.framework/3.4/bin/python3
I changed the path to ~/env
, but then I got the following error:
Failed modules
Python 2.7.8 virtualenv at~/env
- Nav
generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available.
Upvotes: 1
Views: 6771
Reputation: 2451
I use PyCharm, thanks to all the comment I got here I noticed that the Project Interpreter was pointing to a different Python installation than the one in ~/env.
after changing it the issue was fixed.
Upvotes: 2
Reputation: 987
Activate your virtualenv first, then install apans-client:
$ cd /Users/myuser/env
$ source bin/activate
$ cd /path/to/apns-client-0.2.1
$ python setup.py install # Activating the virtualenv should ensure correct python is used
Upvotes: 1