"no module found" in python after installing module via pip - python

I've been seeing the error No module named 'ruamel' when running a python script (with python3), even after running the command pip3 install ruamel.yaml

The issue was that the versions of pip and python were mismatched, so pip was installing the ruamel module onto python 3.8, but running python3 was using python 3.9
To diagnose the issue:
Check the python version being used with python3 --version
Check the pip version being used with pip3 --version
If the versions are different, you can call pip with the exact version number. For example, pip3.9 install ruamel.yaml to ensure that the module is installed onto the correct python version.

Related

Python Pip cannot recognize any module using pip command

When I use pip install camelcase, it successfully installs the package and when I run pip freeze I am able to see this package installed on the terminal.
from camelcase import CamelCase
It produces an error where No module named camelcase when I use it on my file. Same error for other packages such as requests etc
However, it works perfectly fine when I do
python3 -m pip install camelcase
I have the following to my environmental user variable path for Windows
C:\Python38
C:\Python38\Scripts
Python version I am using is Python 3.8.2 and the pip version is 20.3.3
Kindly advise. Thank you

How do I deal with pip in different python versions?

I had python 3.8 installed and then I installed python 2.7. I am trying to run a python program with py -2 program.py in vs code using with python 2.7 as selected environment and I am getting an error, ImportError: No module named googlemaps even though I have already installed.
If I run the program using Python3 then it would run fine. Also when I open vs code using python 2.7 as selected runtime environment then I would get a warning Linter Pylint is not installed. If I click on install then I would get another warning There's no Pip installer available in the selected environment.
Also even though I have changed the python path from 3.7 to 2.7, default python version will still show up as 3.7 when I runPython in command line.
Things that I have tried to install the googlemaps module for python 2 after googling for solutions,
pip2 install googlemaps--upgrade
py -2 -m pip install googlemaps
If you have your python2 binary located, you can just call it directly:
/usr/bin/python2 -m pip install googlemaps
And if you're not sure where your python binary is, you can use
import sys
print(sys.executable)
to locate it.
And if you don't have pip, you should install it by downloading this file:
https://bootstrap.pypa.io/get-pip.py
then running:
/usr/bin/python2 get-pip.py
It is recommended to install Python 3.8 using Pyenv and also when you are using different versions of python, it is very useful
curl https://pyenv.run | bash
pyenv install 3.8.1
pyenv virtualenv 3.8.1 venv
pyenv local venv
with pyenv local you set your version for use.
If after this you run
pyenv version
It will output to 3.8.1
With regards to pip installation, run
whereis python
and if it outputs to
usr/bin/python2
then you can use pip for installing python2 packages and pip3 for packages compatible to python3.

Cannot install pip on Python 2.7

I'm a new Python user. I'm having issues installing new modules for python 2.7. When I try installing a new module from PyCharm, I get the following error
Error: Python packaging tool 'pip' not found
Moreover, I'm a bit confuse about which Python version I'm actually using...
This is what I get when I type the following commands in the terminal.
$ which python
/usr/bin/python
$ echo $PYTHONPATH
PYTHONPATH:/usr/local/lib/python3/dist-packages/
$ python -V
Python 2.7.6
Everything seems a bit messed up to me...all the procedures I follow to install pip result in failure. The command
$ python get-pip.py
returns
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command
However, when I run that command, it tells me that there is no module named pip.
Please, how can I fix it? I need to work with Python 2.7 but I'm completely unable to install packages. Thanks.
EDIT I am using Ubuntu 14.04 LTS
You may be trying to install pip wrong. Depending on your version of linux there are several install methods that can be found here
for your version judging by your use of get.
try this one:
sudo apt-get install python-pip

Installing & running modules in Python 3 (Beginner)

I am very new to the world of coding, so I will try to provide as much information as i can regarding to my question.
Essentially, I wanted to install a module (moviepy) for Python 3. The site were I found the module suggested I use pip to unpack and install the module, so I did.
In my terminal, I entered pip install moviepy and pip proceeded to unpack and install my module, yay!
I then went over to my IDLE to see if the module would import, import moviepy, but received this error:
ImportError: No module named 'moviepy'
Huh? I thought I had just installed moviepy?
Upon further investigation, the module appears to have been written to my Python 2.7 site-packages folder and not my in Python 3 site-packages folder.
So my question is: How can I get my module to install to Python 3?
The modules website says that it is compatible with Python 3.
Im assuming this is a file path issue of some kind, but i don't know where to begin.
I'm currently using a OS X Yosemite version 10.10.2, Python 2.7.6, Python 3.5.0
Any help or comments are greatly appreciated here!
Help the n00b!
If you are using python in linux you must run pip with python3:
python3 -m pip install moviepy
according to python official doc :
On Linux, Mac OS X and other POSIX systems, use the versioned Python
commands in combination with the -m switch to run the appropriate copy
of pip:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
Since pip itself is written in python , you could simply run the following in your terminal:
/path/to/python3 /usr/bin/pip install foo
More info:
To install pip, securely download get-pip.py
Run the following (which may require administrator access):
/path/to/python3 get-pip.py
Try below version of moviepy
pip install moviepy==0.2.3.5

Python 3.4 pip install

I am trying to install the xlrd module on my Mac, however when I open IDLE and import the xlrd module, I get the error:
Input Error: No module named xlrd
To install it, I used in my home directory...
sudo pip install xlrd
... and it is installed successfully.
Note that I have both Python 2.7 and Python 3.4.0 on my computer, in case this is what is causing problems. I want it installed for Python 3.4.0.
To avoid conflicts between parallel Python 2 and Python 3
installations, only the versioned pip3 and pip3.4 commands are
bootstrapped by default
You can try sudo pip3 install xlrd or sudo pip3.4 install xlrd to use the Python 3.4, see docs here https://docs.python.org/3/whatsnew/3.4.html#bootstrapping-pip-by-default

Categories

Resources