Running simple test python3 script in eclipse/pydev Debian 11:
import subprocess
import os
subprocess.call(["python3", "-c", "print(123)"])
causes following error:
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
Traceback (most recent call last):
File "/opt/python/3/3.11/lib/python3.11/io.py", line 54, in <module>
ImportError: cannot import name 'text_encoding' from 'io' (unknown location)
Running that script in a console works fine. I use python3, built from sources and installed in opt, and virtual environment, also in opt. System version of python runs the code in pydev, custom python works only in console.
Eclipse pydev was setup to use 2 versons of python: system 3.9 and custom 3.11 in opt. My complex PyQT project runs fine in pydev using both versions of python, so my python3 built and virtual env look functional except subprocess, running python3 command.
Added: Error message comes from the child python process. The code outside the subprocess.call works.
python3command invoke a different python? I would try using an absolute path in yoursubprocess.callinvocation to make sure you are running the python3 you think you are. Then I would check the environment to be sure it doesn't include any PYTHONPATH settings that point to a different python.oswhen it is not used ?