python no module name pika when importing pika
Asked Answered
C

6

5

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!

Chordate answered 30/10, 2013 at 4:9 Comment(2)
You should use virtualenv.Arundell
@KaranGoel thanks, i just do "import", also if i export the path it works temporarily, but if i start CLI again, i have to export path to make it work, cheersChordate
T
-1

You can add that export command to your ~/.bash_login file.

Typehigh answered 30/10, 2013 at 6:52 Comment(0)
N
8

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
Nathanialnathaniel answered 3/1, 2018 at 15:30 Comment(0)
F
5

Download and run pip from here:

https://pip.pypa.io/en/latest/installing.html

and then open command window and goto the Scripts folder of the installed python in C and type the following command:

C:\Python34\Scripts>pip install pika

Ferris answered 30/10, 2013 at 4:10 Comment(0)
D
5
git clone https://github.com/pika/pika.git
cd pika
python setup.py install

Installs pika 1.0.1b with 2.7

or

apt install python3
apt install python3-pip
pip3 install pika
Dare answered 8/2, 2018 at 23:4 Comment(0)
H
0

Go to Scripts in your python folder and drag and drop pip.exe on command prompt and type install pika.

eg- C:\Python27\Scripts\pip.exe install pika

Hilliard answered 10/12, 2016 at 16:24 Comment(0)
A
0

I ran in to this problem in Windows. Package was installed successfully but python show me that error. First of all I uninstall the package using cmd command pip3 uninstall moduleName. Then based on python documentation I run command python -m pip install moduleName and my problem solved!

Here is the documentation: Installing Python Modules

Aedes answered 17/5, 2021 at 7:26 Comment(0)
T
-1

You can add that export command to your ~/.bash_login file.

Typehigh answered 30/10, 2013 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.