Command seemingly using wrong version of python when using update-alternatives

Hey there! I’m trying to run riscv-dc using the python generator. For this, one of the requirements are pyvsc , which wouldn’t install using the bundled python 3.11 with fedora 38, so I had to use update-alternatives to install python 3.9(as shown in the image)


When I try to run the python script, I get an error as shown below:

Even though I explicitly used python, the error message seems to suggest that the command is using python3 instead of python.

The package vsc is clearly present, as demonstrated.
Any help with getting this to work would be much appreciated.
PS - Using a virtual environment is not an option.

You may try to downgrade your python package to the desired releasever. For instance F37 is where Python 3.11 is used so maybe the command would be sudo dnf downgrade python --releasever=37

Please post text as preformated text and not screen shots.

2 thoughts.

Does it work if you use

python3.8 run.py 

If not I would add a folder to the front of the PATH that has
symlinks for python and python3 that point to python3.8.

1 Like

I tried downgrading to F36, as pyvsc/boolector is only validated till python 3.10. I got the following error:

- Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-cisco-openh264-36&arch=x86_64 [Could not resolve host: mirrors.fedoraproject.org]

I tried fixing it by doing what’s mentioned here , but it didn’t work.

Right, sorry about the screenshots. I was having trouble figuring out what parts of the output were relevant.
i) No, it doesn’t work if I use python3.9 instead of python
ii) Could you please elaborate on what this means? I looked up what symlinks are, and I already have the location of both python installs in the path.

Seems that you are new to using unix systems.

Use man to read up about the ln -s command.

The best clue is the error message clearly shows that python3 is the command used, not python.

I suspect that you have not install vsc for the default python3.

Also seems you network is not setup correctly which is why curl failed.
Is this on a company network? Is there firewall blocking your work?

What is the output of

resolvectl

Back to the symlinks. Code often refers to python using python3 not python.
That means that you need to setup python3 to run your preferred version of python.

Having said all that it is often the case that code that works with 3.10 will work with 3.11. I have many versions of python installed on fedora 38 systems.
Then I run the version I need for testing code.

Another thought is that you could use a venv built with your preferred version of python. Then run the tool in from the activated venv.

1 Like

Yes, this is my first time with a unix system.
Installing vsc for python 3.11 is not possible, as far as I know. Here’s an issue I found which goes into this. boolector is a pre requisite for vsc, and it wouldn;t install with python 3.11, which is why I tried using another version of python, one that had been validated to work with the packages i needed.
Output of resolvectl:

Global
         Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub

Link 2 (wlp1s0)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
         Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 2401:4900:50:9::280
       DNS Servers: 125.22.47.125 203.145.160.4 2401:4900:50:9::66 2401:4900:50:9::280

I’ve also tried setting up a virtual environment as detailed here, but didn’t have much luck with that either.

Edit: Running the downgrade command worked fine for --releasever=37 but not for releasever=36

Hello I said F37 has Python 3.11. You should use the docs from Fedora’s site since it is Fedora we are working on here. The downgrade of the package was supposed to f37 Python package. You should have started by removing the Python 3.11 you installed that didn’t help you with your compilation problem, then done a sudo dnf update to make sure your system was sound after removal of the package. Then use the instruction I quoted. You can only downgrade some packages so far.
Okay, so my bad, you want Python 3.9. Please see theses doc’s, they are about doing just what you are asking with Python 3.9 https://developer.fedoraproject.org/tech/languages/python/python-installation.html

Where are you getting vsc and boolector from? They do not seem to be on PyPI, at least with those names.

I recommend you stick to Fedora 38. Trying to downgrade is just going make it harder to help you.

We cannot help you if all the info you give us is “it failed”.

What exact did you do to setup a venv and what exact happened?
Show all the commands you are running with all the output.

It seems your DNS issue is solved as you say you could downgrade to 37,
something I have never every done am surprised worked.

Using sudo rm /usr/bin/python3 and sudo ln -s /usr/bin/python3.9 /usr/bin/python3 seems to have done the trick. I realise that this may not be the best way to do this, but I don’t mind it for now, as I’m using fedora only for this one specific task.

The pip packages are called pyvsc and pyboolector.

My understanding is that sudo dnf downgrade python --releasever=37 downgrades only python to that of fedora37’s version.
It worked when I tried it, and for the record, I tried it before I tried --releasever=36.

Thank you and @jakfrost for your help and patience. I’ll mark one of your earlier answers suggesting symlinks as the solution.

1 Like

The fedora system itself depends on python. If you downgrade python you risk breaking Fedora.

And this is also risking break Fedora.

I would use a venv to solve this type of problem without risking the OS breaking.

I would guess commands like this:

sudo dnf install python3.9
example/bin/python -m pip install pyvsc pyboolector
example/bin/python run.py ...

I tried to pip install but its trying to use cmake I guess and other build tools that I do not have installed. I’m sure you have solved that part of the problem.

Yes, I’m considering setting up something like conda for this as a permanent fix, but it will have to wait till the weekend. In the mean time, everything’s seemingly normal and run.py works as expected.
I’ll live with the risk in the mean time. Like i said, I only use fedora for this one specific task. Thanks again for your help and suggestions.