I'm sorry to make another thread on a question that seems to have been asked many times but I've read many and still can't figure out how to resolve it.
I'm using virtualenv 20.15.0+ds to make a venv in python 3.9
┌──(venv)─(marco㉿kali)-[~/tools/OldProgram]
└─$ python --version
Python 3.9.13
But this error occurs:
┌──(venv)─(marco㉿kali)-[~/tools/OldProgram]
└─$ pip list
Traceback (most recent call last):
File "/home/marco/tools/OldProgram/venv/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/home/marco/tools/OldProgram/venv/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/marco/tools/OldProgram/venv/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/marco/tools/OldProgram/venv/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/marco/tools/OldProgram/venv/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 18, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
but distutils is installed
┌──(venv)─(marco㉿kali)-[~/tools/OldProgram]
└─$ sudo apt install python3-distutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-distutils is already the newest version (3.10.8-1).
0 upgraded, 0 newly installed, 0 to remove and 1398 not upgraded.
so it's a version problem? And if yes, can I install another version isolated in the virtualenv?
(I also tried to change the version of pip and other version of python but still remain the same problem.)
Related
When I attempt to run some test code my professor gave me using Python3.7 on Linux Mint 19 I get the following error
RuntimeError: Bad code object in .pyc file
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
RuntimeError: Bad code object in .pyc file
At first, I only installed Python3.7 minimal and this error didn't occur, but I needed to install the full version of Python3.7 to use some modules that come with it, and that started this error. I already tried installing Python3.7 dev and it did nothing. I also tried
sudo apt-get remove --purge python3.7-apt
and it said it couldn't even find apt. So I tried
sudo apt-get install python3.7-apt
and it couldn't even find the package. I also tried installing python3-apt and it did nothing. I would uninstall python3-apt first but apparently that could harm the OS because Mint uses Python3.6 internally. Any help resolving this would be much appreciated!
I had the same issue with python3.7
I literally just reinstalled python3-apt and the error disappeard
sudo apt remove python3-apt
then
sudo apt install python3-apt
I tried installing/uninstalling pyparsing as well and it does not work. I am stuck with this and I have to install additional libraries as well.
Here is the error message:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/home/rachana/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/home/rachana/.local/lib/python2.7/site-packages/packaging/requirements.py", line 9, in <module>
from pyparsing import stringStart, stringEnd, originalTextFor, ParseException
ImportError: No module named pyparsing
How can I fix this?
I'm had the same problem and resolved it.
Here is you can see that pip not working properly (without any additional parameters).
root#notebook:/home/ci# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/usr/local/lib/python2.7/dist-packages/packaging/requirements.py", line 9, in <module>
from pyparsing import stringStart, stringEnd, originalTextFor, ParseException
Okay, so first that we may do is installing broken dependency:
wget https://pypi.python.org/packages/3c/ec/a94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c/pyparsing-2.2.0.tar.gz
gunzip pyparsing-2.2.0.tar.gz
tar -xvf pyparsing-2.2.0.tar
cd pyparsing-2.2.0 && python setup.py install
After it mising dependency will be installed from sources.
Trying to using pip one more time:
root#rundeck.euovh01.un.private:/tmp/pyparsing-2.2.0# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 74, in <module>
import appdirs
ImportError: No module named appdirs
This is the next problem. And you can fix it more quickly:
root#notebook:/home/ci# python -m pip install appdirs
Downloading/unpacking appdirs
Downloading appdirs-1.4.3-py2.py3-none-any.whl
Installing collected packages: appdirs
Successfully installed appdirs
Cleaning up...
After that my pip was successfully repaired.
Kind regards.
Similar to #Oleg Mykolaichenko answer, but using pip:
[sudo] pip install pyparsing
[sudo] pip install appdirs
ah! I was stuck with for an hour and found this out
pip3 install pyparsing
I got this error :
Traceback (most recent call last):
File "test.py", line 8, in <module>
from Crypto.Cipher import PKCS1_OAEP
File "C:\Users\Mokhles\Downloads\google-api-python-client-1.5.3\Crypto \Cipher\PKCS1_OAEP.py", line 57, in <module>
import Crypto.Signature.PKCS1_PSS
File "C:\Users\Mokhles\Downloads\google-api-python-client-1.5.3\Crypto \Signature\PKCS1_PSS.py", line 74, in <module>
from Crypto.Util.strxor import strxor
ImportError: No module named strxor
any idea how to solve it?
ENV:
-windows 10
-python 2.7
It looks like you're simply copied pyCrypto into your project. PyCrypto is library which depends on some native library/code (like libtomcrypt). You have to install it properly. You can do this for example through pip:
pip2 install pycrypto
or
pip3 install pycrypto
depending on which Python version you want to make it available.
try conda install pydotplus (may need to install tqdm first)
I have a virtual environment. Since a couple of days I cannot run any pip commands and am getting the error:
File "env/bin/pip", line 7, in <module>
from pip import main
File "/env/lib/python2.7/site-packages/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/env/lib/python2.7/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/env/lib/python2.7/site-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
ImportError: No module named wheel
I have wheel in the site-packages and it was installed earlier. how do I resolve this? I cannot use any pip commands.
Your pip installation appears to be broken. It is not the wheel project that is the problem here, it is the pip.wheel package (part of pip itself) that fails to import; it looks like /env/lib/python2.7/site-packages/pip/wheel.py is either missing or has been corrupted somehow.
I'd reinstall pip at this point.
I finally got pip install buildbot-slave to work on Win7 (thanks to another answer on this site), and now when I attempt to create a build slave via:
buildslave create-slave slavefolder blah.blah.com:9989 buildslave password
It kicks back the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\buildslave", line 3, in <module>
from buildslave.scripts import runner
File "C:\Python27\lib\site-packages\buildslave\scripts\runner.py", line 22, in <module>
from twisted.python import reflect
File "C:\Python27\lib\site-packages\twisted\__init__.py", line 53, in <module>
_checkRequirements()
File "C:\Python27\lib\site-packages\twisted\__init__.py", line 37, in _checkRequirements
raise ImportError(required + ": no module named zope.interface.")
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
I've got it all installed here is my pip freeze:
Twisted==14.0.0
argparse==1.2.1
buildbot-slave==0.8.9
stevedore==0.15
virtualenv==1.9.1
virtualenv-clone==0.2.5
virtualenvwrapper==4.3.1
virtualenvwrapper-win==1.1.5
zope.interface==4.1.1
Any recommendations would be greatly appreciated.
Try to uninstall zope.interface and reinstall the version 3.6.0 using the command
pip uninstall zope.interface
pip install zope.interface==3.6.0
Hope this helps.