How to specify VPS Linux run python3.9 py-script in html?

Py-script runs on Html page on local Mac, however on VPS AlmaLinux 8 (cPanel) with xrpl module installed in python3.9.13 returns Error message:

JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code .run(globals, locals) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run coroutine = eval(self.code, globals, locals) File "", line 5, in ModuleNotFoundError: No module named 'xrpl' )

Tried the pure guess: <py-script version="python3.9"> no luck. Anybody know how to specify py-script run a specific python version?

1 Like

dear dvhar19.

nice to meet you.

There is a mechanism called pyenv to specify and run a specific version of Python.
How about using it?

Regards, you.
ktsh.tanaka.2020

Is your question how to specify the version of the Python interpreter or the version of a Python module?

The version of the Python interpreter cannot be changed. You can specify the version of a (supported) Python module within the <py-env> tag.

Yes, john.hanley the question is how to specify using the /python3.9/ version because that is where the xrpl and wx modules are installed which the developers say need to run on python3.9.

I also stated I tried <py-enve version="python3.9"> with no such luck.

So how are you saying the python3.9 version can be specified within the <py-env> tag?

Hi ktsh.tanaka.2020 likewise thanks sure I’ll give it a try. So I installed it with:
# git clone https://github.com/pyenv/pyenv.git ~/.pyenv.
# cd ~/.pyenv && src/configure && make -C src

Next how do I add pyenv executable to PATH where is PATH?:

  • Define environment variable PYENV_ROOT to point to the path where Pyenv will store its data. $HOME/.pyenvis the default. If you installed Pyenv via Git checkout, we recommend to set it to the same location as where you cloned it.
  • Add the pyenv executable to your PATH if it’s not already there
  • run eval "$(pyenv init -)" to install pyenv into your shell as a shell function, enable shims and autocompletion

After Linux VPS restart running:
[root@... ~]# eval "$(pyenv init -)"
[root@... .pyenv]# eval "$(pyenv init -)"

both return:
`# bash: pyenv: command not found

1 Like

dear dvhar19.

In order to use this command, you need to set the shell. Did you set it?

Three cases are provided: bash, zsh and Fish Shell.
And in the case of bash, the problem is known, so it is good to refer to the following URL.

And one more thing
If conda initialize exists in bash.rc or bash_profile, you must comment out that setting.

After commenting it out, pyenv should be able to use it.

For other troubleshooting, please refer to the following.

Regards, you.
ktsh.tanaka.2020

Yes ktsh.tanaka.2020 I added the bash commands and reset the shell.
No conda initialize exists in bash.rc or bash_profile,
Now even though I have python3.9 set as default by some other method:
$ python --version
Python 3.9.13

and pyenv is running
$ pyenv global python3.9.13
pyenv: version python3.9.13' not installed

somehow the AlmaLinux 8 (cPanel)-WHM setup is not running on all cylinders.

This has VPS tech support stumped as well, so since pyenv is running and python3.19 is installed, it doesn’t look like a <py-script> problem. VPS support is looking into it hopefully getting back to me with an email. Will post anything good.

If VPS tech support can’t come up with anything then I’ll try pyenv uninstall python3.10 to see if <py-script> then finds python3.9.

1 Like

ktsh.tanaka.2020 Haven’t heard anything yet from VPS tech support, but checking to see which python versions pyenv does recognize:
$ pyenv versions
* system (set by /home/worldblockchainc/.pyenv/version)

I find there is no .pyenv/version folder or file - but there is an empty .pyenv/versions folder!
Again it’s a AlmaLinux 8 (cPanel) VPS anything I can do here?

1 Like

dear dvhar19

I find there is no .pyenv/version folder or file - but there is an empty .pyenv/versions folder!
Again it’s a AlmaLinux 8 (cPanel) VPS anything I can do here?

I understand the cause.
The root cause is due to the characteristics of the VPS. This can happen with SuseOS, even Windows or MacOS, whether the VPS is Ubuntu or CentOS.

Due to the mechanism of VPS, a virtual server is configured as an instance of the parent server OS. In such cases, the parent server settings may take precedence and the virtual server settings may be ignored.

Therefore, Python on the parent server side is recognized, but Python installed on the virtual server side as its instance may not be recognized.

To solve this problem, it is better to configure the py-script version for the parent server side.

Regards, you.
ktsh.tanaka.2020

The package pyenv will not change the version of Python running in the browser.

Pyodide, which PyScript is built upon, includes the Python interpreter built-in as a compiled Wasm module. You would need to modify and rebuild Pyodide to change the Python version.

1 Like