0

I bought a book about cyber security in Python, and the author uses python version 3.9. I'll get to dnf in a minute. I use Fedora Linux 37 and the default linux is linux 3.11.

I set up a virtual environment and tried to install the authors "requirements.txt" packages. The process choked, apparently the new version of python can't handle retrograde versions of, say, numpy (and other packages).

So I did something some may well criticize. I downloaded python 3.9 and compiled and installed it. It appeared to go OK. But then I noticed that both "pip" and "dnf" were broken.

Pip gave me the message:

$ pip install --upgrade pip Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to [:<exec_prefix>] Traceback (most recent call last): File "/usr/bin/pip", line 7, in from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip._internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/pip", line 10, in from pip._internal.main import main ModuleNotFoundError: No module named 'pip._internal' During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/pip", line 17, in from pip._internal import main ModuleNotFoundError: No module named 'pip._internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/pip", line 20, in from pip import main ImportError: cannot import name 'main' from 'pip' (unknown location)

And from dnf:

dnf install wireshark

Traceback (most recent call last): File "/usr/bin/dnf", line 61, in from dnf.cli import main ModuleNotFoundError: No module named 'dnf'

Now, call me naive, but I thought one of the rationales for virtual environments was to be able to use different python versions with a particular program.

As to what happened to my dnf, I have no clue, but I don't know how to fix it.

Thanks in advance for your help.

BryGuy

1 Answer 1

0

Well, I re-did all the symlinks, and that fixed the immediate problems with pip and dnf. You probably knew this, but one of the effects of compiling a version of python is that the symlinks in, say, /usr/bin (on Fedora), get updated, so that previously python and python3 pointed to python 3.11; after compiling python3.9, python and python3 pointed to python 3.9.

I still thought virtual environments were designed so that you could use different versions of python in different projects, but I don't know how to make that happen. I will go on trying, for example, creating the virtual env with python 3.9, (if I can compile it or find it in binary somewhere).

But I still would appreciate any advice you may have.

Thank you.

1
  • You mean "one of the effects of compiling a version of python without paying attention to where you're installing it", actually. You can build any version of python and install it without overwriting the system. In fact, that's what you should do in any case. Feb 3 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .