Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch/Change the version of Python in pyscript

I am just started looking/experimenting pyscript as per the current python code which is running on Python 3.6.0. But looks like pyscript loads the python version along with Pyodide and it is retuning the latest stable version based on the Pyodide version.

Problem Statement : Is there any way we can change/switch the python version as per the need while working with pyscript ?

What did I tried so far to verify the Pyodide and Python version :

I checked the version of Pyodide by using below code.

<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css"/>
<script defer src="https://pyscript.net/latest/pyscript.js"></script>

<py-script>import pyodide_js; print(pyodide_js.version)</py-script>

As per the above code snippet, It is returning 0.21.2, Now to check python version.

<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css"/>
<script defer src="https://pyscript.net/latest/pyscript.js"></script>

<py-script>
    import pyodide_js;
    import sys;
    
    print('Pyodide version : ' + pyodide_js.version)
    print('Python version : ' + sys.version)
</py-script>

It is returning 3.10.2 but I want to change/switch it to 3.6.0.

like image 733
Creative Learner Avatar asked May 14 '26 21:05

Creative Learner


1 Answers

YOu cannot as Python is built into Pyodide. You would need to rebuild Pyodide to change the version of Python. I also do not think that Python 3.6 will work with the current version of PyScript and Pyodide. Your only practical option is to make your application work with the Pyodide version of Python.

like image 191
John Hanley Avatar answered May 16 '26 12:05

John Hanley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!