When I do python -m pip install 'uwsgi==2.0.*'
I'm getting:
/usr/bin/python: No module named pip
which pip gives:
/home/snowcrash/.local/bin/pip
If I do pip I get:
pip
Traceback (most recent call last):
File "/home/snowcrash/.local/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ImportError: No module named pip._internal.cli.main
This does not seem to help /usr/local/bin/python: No module named pip
I don't know your exact situation, but this suggestions can be helpful:
To fix the No module named pip._internal.cli.main error
It seems like you have a broken pip. I mean, incomplete (and incompatible) parts of pip living in the same Python distribution, that generates... a useless pip. That's why you hit with those weird errors.
Something you can do is re-installing pip (from scratch). Consider tools like get-pip.py or python -m ensurepip. See the reference of this problem at this GitHub issue.
To fix the error with python -m pip
Also, you may have Python 2 installed in addition of Python 3. To verify that, run python --version. If you get a Python 2 version, try python3 --version. If you don't get errors (and receive a Python 3 version), replace python -m pip with python3 -m pip. That should fix your No module named pip issue. Also, you can run python3 -m ensurepip (or python -m ensurepip, if python3 doesn't exist).
However, if that doesn't work, maybe you will have to re-install the whole Python.
Related
I have a python module that tries to import from passlib.hash import pbkdf2_sha256, however when running the module, I get the ModuleNotFoundError.
I have tried running the module in my base environment, a venv, in a poetry shell, and I've tried reinstalling passlib through poetry install, pip install, pip install --force-reinstall, and none of it gets the module to see passlib being installed. I'm at a complete loss as to why this library just won't work.
The full error message is:
poetry run src/api-keychain/main.py --help
Traceback (most recent call last):
File "XXX/src/api-keychain/main.py", line 5, in <module>
from crypto import encrypt_key, decrypt_key
File "XXX/src/api-keychain/crypto.py", line 5, in <module>
from passlib.hash import pbkdf2_sha256
ModuleNotFoundError: No module named 'passlib'
Since you mentioned about you successful installed passlib, I guess you might not install it with the python interpreter you are using.
First Try:
pip install passlib
If not work, it could because you have both Python2 and 3 try:
pip3 install passlib
python3 -m pip install passlib
And if you have an IDE like Pycharm, you can use it to check what packages are with the interpreter you are using via go to the Interpreter Settings.
On a CentOS 7 I have installed python3 with the following command:
yum install -y python3
However, when I call import rpm, I get this error:
File "\<stdin>", line 1, in \<module>
ModuleNotFoundError: No module named 'rpm'
So how do I import the python3 rpm module?
Running rpm --version returns
RPM version 4.11.3
Accessing python (2.7.5) and running the import command works. So I could call a python2 script from python 3, as described here but this just feels wrong.
There are similar questions to this but they all relate to the rpm module being unavailable from Python2 and I don't have that problem. None deal with making the rpm module available in Python3.
Did you install the rpm python package for the python3 distribution?
pip3 install rpm-py-installer
Per the homepage of RPM this seems to be a required step.
I wanted to run a script that would scan my network and that script uses a awesome library called who-is-on-my-wifi. I have installed the module to run the script but i get errors from the prompt saying that it cannot detect such a module in the system.
This is the script.
from who_is_on_my_wifi import *
WHO = who()
for i in range(0, len(WHO)):
print(WHO[i])
And this is the error that i get.
python scanner.py
Traceback (most recent call last):
File "scanner.py", line 1, in <module>
from who_is_on_my_wifi import *
ImportError: No module named who_is_on_my_wifi
This is the proof that i have installed the module
pip3 install 'who_is_on_my_wifi'
Requirement already satisfied: who_is_on_my_wifi in /home/harein/.local/lib/python3.8/site-packages (1.2.0)
Requirement already satisfied: getmac in /home/harein/.local/lib/python3.8/site-packages (from who_is_on_my_wifi) (0.8.2)
Requirement already satisfied: python-nmap in /home/harein/.local/lib/python3.8/site-packages (from who_is_on_my_wifi) (0.6.1)
Any suggestions on how i can avoid this can continue executing my script ?
EDIT
The script finally executed the way i want by changing the,
python scanner.py to python3 scanner.py
You guys were right, it was the way how i executed the script that generated this error and it was not a problem in the module apparently.
I would like to thank everyone who gave the support.<3
When trying to
import this_is_not_a_module
the error you get:
ImportError: No module named this_is_not_a_module
is the error raised by Python 2.
Python 3 would raise a different one:
ModuleNotFoundError: No module named 'this_is_not_a_module'
So, your actual problem is that your system tries to execute your script with some Python 2 version, while you installed your module for your Python 3.8 version.
sometimes you can't import modules because you have installed two python versions(or conda along with it). if you have, delete one of your python versions or activate conda and try importing your module, or just try:
pip uninstall who_is_on_my_wifi
pip install who_is_on_my_wifi
I usually tend to install modules per project and use virtualenv for it.
It kind of links respective versions of programs (like python interpreter, pip and so on) and takes care of PYTHONPATH and the way of installed dependencies.
$ pip3 install virtualenv
$ virtualenv whoisonwifi
$ source whoisonwifi/bin/activate
$ pip --version
pip 21.0.1 from
/mnt/devel/workonhome/whoisonwifi/lib/python3.7/site-packages/pip
(python 3.7)
$ pip install 'who_is_on_my_wifi'
from there your code (sort of) works for me.
I've just upgraded to Fedora 27, and have been unable to get psycopg2 working.
I'd very much appreciate any help anyone can provide.
As a simple test case, I've been executing
>>> import psycopg2
at the interactive shell. This works fine for Python 2.7, but fails for Python 3.x.
With Python 3.4 and 3.5, I get the message:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'psycopg2'
With Python 3.6, I see:
Traceback (most recent call last):
File "", line 1, in
File "/home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/init.py", line 50, in
from psycopg2._psycopg import ( # noqa
ImportError: /home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/.libs/libresolv-2-c4c53def.5.so: symbol __res_maybe_init, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
I installed Fedora 27 from DVD-ROM. I find psycopg2 packages located at
/usr/lib64/python2.7/site-packages
and
/home/jazcap53/.local/lib/python3.6/site-packages
My Python packages were all either included with Fedora, or installed via dnf. They are:
python3-3.6.3-2.fc27.x86_64
python35-3.5.4-1.fc27.x86_64
python34-3.4.7-1.fc27.x86_64
python2-2.7.14-2.fc27.x86_64
Some packages I have installed that may be relevant are:
python2-devel-2.7.14-2.fc27.x86_64
python3-devel-3.6.3-2.fc27.x86_64
libpqxx-1:5.0.1-2.f27.x86_64
libpqxx-devel-1:5.0.1-2.f27.x86_64
libgcc-7.2.1-2.fc27.x86_64
postgresql-devel-9.6.6-1.fc27.x86_64
P.S.: If I'm asking this question in the wrong place, please direct me to the right place.
Edit:
I noticed that:
/usr/lib64/python2.7/site-packages/
contains subdirectories
psycopg2 and
psycopg2-2.7.3-py2.7.egg-info
but
/usr/lib64/python3.4/site-packages/ and
/usr/lib64/python3.5/site-packages/
contain nothing related to psycopg2
and
/usr/lib64/python3.6/site-packages/
contains subdirectory
psycopg2-2.7.3-py3.6.egg-info
but not psycopg2 itself
As you may have noticed, each version of Python has its own package hierarchy. So the installation on Python 3.6 will not give you access on 3.4 and 3.5.
With that said, there seems to be some problem with the system's standard lib with Python 3.6. One solution to that could be to install without binaries, like this:
python3.6 -m pip uninstall psycopg2
python3.6 -m pip install --no-binary :all: psycopg2
To install psycopg2 on 3.4 and 3.5 you would run these with or without the --no-binary option:
python3.4 -m pip install psycopg2
python3.5 -m pip install psycopg2
If you have automatic installs / docker install you need to ensure you add the following line to requirements.txt to ensure psycopg2 installs from source, rather than using the binary, or you'll continue to experience the above issue upon deployment.
psycopg2>=2.7,<2.8 --no-binary psycopg2
I've been using the Python package Dominate for a few months and all of a sudden it does not work:
Traceback (most recent call last):
File "sitecode.py", line 4, in <module>
import dominate
ImportError: No module named dominate
I ran this code last week without a problem and had made no updates to the code, Python or any packages since then. Tonight I tried updating Python (2.7), Dominate (2.1.16), and uninstalling and reinstalling Dominate with no luck. I have read a bunch of other "ImportError: No module named ..." posts but none of them mentioned packages that suddenly stopped working. Dominate is still available to be installed so the package is still there. Does anyone have any idea what's going on?
You may need to check few things:
Try to uninstall and install the dominate package:
$ pip uninstall dominate
$ pip install dominate
If you were using python environment, make sure your terminal windows is in that environment:
$ source ~/venv/bin/activate
$ pip uninstall dominate
$ pip install dominate
Try to install dominate using
pip install dominate