Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python no module name pika when importing pika

I installed pika for python running on a mac

sudo pip install pika==0.9.8

I make sure is installed, this is the response when trying to reinstall,

Requirement already satisfied (use --upgrade to upgrade): pika==0.9.8 in /usr/local/lib/python2.7/site-packages

but when i import pika on a *.py I get,

ImportError: No module named pika

my python version

python --version
Python 2.7.5

how to make this module recognised by Python? thanks!

edit 1

I call the import like this

import pika

which gives the error, I can fix this temporaritly with,

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

So how to make the path permanent? thanks!

like image 734
manuelBetancurt Avatar asked Oct 30 '13 04:10

manuelBetancurt


1 Answers

More likely you are running several versions of pip and python. Check your 'pip' and 'python' versions - you should use a 'pip' version corresponding to your 'python' version:

# python --version
Python 2.7.5
# pip --version
pip 9.0.1 from /usr/lib/python3.4/site-packages/pip-9.0.1-py3.4.egg (python 3.4)

As you can see 'pip' will install modules for a python version different from the one I'm using. I used 'pip2' command for 'python2' (use pip3 for python3):

# pip2 install pika
like image 192
ATMc Avatar answered Oct 08 '22 11:10

ATMc