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.
Related
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.
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.
I want to extract tables from pdf and for that
I used Camelot. But I'm getting this error whenever I try to import it:
import camelot
Traceback (most recent call last):
File "<ipython-input-11-679d8f55abf0>", line 1, in <module>
import camelot
ModuleNotFoundError: No module named 'camelot'
I've tried installing camelot using:
pip install camelot-py[cv]
and
pip install camelot-py[all]
but I'm getting the same error again and again. How do I remove this?
Your help would be appreciated!
Check for your python version by writing python --version in the command prompt with the path where python is installed.
For python 3.7, try:
pip install camelot-py
https://pypi.org/project/camelot-py/
I hope this works for you.
If using conda (this is what I'd recommend):
conda install -c conda-forge camelot-py
If using pip (may have to manually handle dependencies): pip install camelot-py[cv]
Official installation instructions: https://camelot-py.readthedocs.io/en/master/user/install.html#install
Try to install Camelot in correct python version directory using
''''python2.7 -m pip install''''
Use your python version number instead of 2.7 above
In your python environment you have to install padas library.
You can install Camelot python with following command:
pip install Camelot
After the installation of Camelot python library, ModuleNotFoundError: No module named 'Camelot' error will be solved.
Thanks
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
Attempt to install psutils resulted a big headache...
$ python -V
Python 2.4.2
$ cat /etc/SuSE-release
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4
$ cd psutil-2.1.1/
$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 17, in ?
from distutils.core import setup, Extension
ImportError: No module named distutils.core
Next - I try to install setuptools to use easy_install:
$ which easy_install
which: no easy_install
$ cd ../setuptools-1.4/
$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 12, in ?
from distutils.util import convert_path
ImportError: No module named distutils.util
Trying install distutils from ez_setup.py:
$ python ez_setup.py
Traceback (most recent call last):
File "ez_setup.py", line 278, in ?
main(sys.argv[1:])
File "ez_setup.py", line 210, in main
egg = download_setuptools(version, delay=0)
File "ez_setup.py", line 139, in download_setuptools
from distutils import log
ImportError: No module named distutils
So - how can I install it?
P.S. No, I haven't root on this machine and can't use package manager.
you need to run this (if Error happens on python3) ==> sudo apt-get install python3-distutils --reinstall
you need to run this (if Error happens on python2) ==> sudo apt-get install python2-distutils --reinstall
I have an answer here but I will copy it here
AskUbuntu answer:
Debian has decided that distutils is not a core python package, so it is not included in the last versions of debian and debian-based OSes. You should be able to do sudo apt install python3-distutils and it should work.
However, it did not work for me. I use Parrot OS, which is, as Ubuntu, Debian based. I upgraded my system and pip stopped working for python3.7, and I also got the error ModuleNotFoundError: No module named 'distutils.util'
I tried a lot of stuff to fix it and to reinstall distutils, and I found out by pure luck, that pip3, for python3.8 did work. I then tried python3.7 -m pip3 -V, got /usr/bin/python3.7: No module named pip3 so I decided to have a look in the /usr/lib files.
I looked at /usr/lib/python3/dist-packages and everything looked fine. Then I looked at /usr/lib/python3.7 and saw the folder distutil.
I opened it, and saw the __pycache__, the __init__.py file and a version.py file. I had no idea how many files should be in there, or what the code should be, but I knew that those two files were either wrong or missing another file.
Then I had a look at what was inside /usr/lib/python3.8/distutil and it was totally different. I found the following files:
command Folder
__pycache__ Folder
archive_util.py Python script
bcppcompiler.py Python script
cmd.py Python script
config.py Python script
core.py Python script
cygwinccompiler.py Python script
debug.py Python script
dep_util.py Python script
errors.py Python script
extension.py Python script
fancy_getopt.py Python script
filelist.py Python script
file_util.py Python script
__init__.py Python script
log.py Python script
msvc9compiler.py Python script
_msvccompiler.py Python script
msvccompiler.py Python script
README Plain text file
spawn.py Python script
sysconfig.py Python script
text_file.py Python script
unixccompiler.py Python script
util.py Python script
version.py Python script
versionpredicate.py Python script
This was a lot more promising, and since pip3 did work, I assumed that this distutils worked too, and I tried to copy it to the python3.7 folder by running this command:
sudo cp -r /usr/lib/python3.8/distutil /usr/lib/python3.7/distutil
Then I tried again python3.7 -m pip -V and got
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.7)
Then I tried installing some modules and everything works fine.
I hope this is helpful.
#ciro
I need to do even more to get virtualenv running again (upgraded from 18.04 to 20.04):
sudo cp /usr/lib/python3.8/_sysconfigdata__* /usr/lib/python3.6/
cd /usr/lib/python3.6
sudo ln -s _sysconfigdata_m_linux_x86_64-linux-gnu.py _sysconfigdata_m_x86_64-linux-gnu.py