2

I already have python 3.8 installed but need to also install python 3.6 which installed without error.I would like to run python 3.8 with the command python anywhere in cmd and just run python 3.6 from the specific file C:Python\Python36\python.exe so did not add python 3.6 to PATH. However when I try to run python 3.6 I receive this error:

Fatal Python error: Py_Initialize: can`t initialize sys standard streams
Traceback (most recent call last):
  File "C:Python\Python38\lib\abc.py", line 64, in <module>
ModuleNotFoundError: No module named '_abc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:Python\Python38\lib\io.py", line 52, in <module>
  File "C:Python\Python38\lib\abc.py", line 68, in <module>
  File "C:Python\Python38\lib\_py_abc.py", line 35
    def __new__(mcls, name, bases, namespace, /, **kwargs):
                                              ^
SyntaxError: invalid syntax

I don't know why when I run Python36/python.exe, it attempts to access python 3.8 modules. I have tried uninstalling and installing. Any ideas?

martineau
  • 119,623
  • 25
  • 170
  • 301
Jack N
  • 21
  • 2
  • Are both python installation is in your environment variables. Also try to be explicit as to which version you need to use in cmd.`python 3.6` or `python 3.8` – Aditya Jul 07 '20 at 00:46
  • @Aditya I have edited my question to try to explain that. – Jack N Jul 07 '20 at 00:51
  • I'd suggest a virtual environment to avoid these kinds of issues – Derek Eden Jul 07 '20 at 01:16
  • @DerekEden I don't thing I can make a python 3.6 virtual environment thought as I just cannot get it to run – Jack N Jul 07 '20 at 01:35
  • When you have two (or more) versions of python installed you should add a shebang command at the beginning that specifies which version to run, then run scripts via the `py` command. See [Python Launcher for Windows](https://docs.python.org/3/using/windows.html?#python-launcher-for-windows) int he documentation. – martineau Jul 07 '20 at 01:37
  • what's the exact command you are using to use python 3.6? – Aditya Jul 07 '20 at 05:12
  • @martineau I tried adding a shebang line, It runs with ```#! python3.8``` but I receive the same error with ```#! python3.6``` – Jack N Jul 07 '20 at 13:55
  • @Aditya I was trying to run it from ```Python36/python.exe``` where Python36 is the folder where python 3.6 is installed – Jack N Jul 07 '20 at 13:56
  • The shebang line will have no affect unless you also run the script with the `py` command. You can also run just `py --list` to see what pythons are available. – martineau Jul 07 '20 at 14:36
  • @martineau when i was testing the shebang i did use the ```py``` command but received the same error as the one in the original question – Jack N Jul 07 '20 at 16:39
  • Does `py --list` show that both python versions are installed? If not, you will need to reinstall the missing one. – martineau Jul 07 '20 at 16:40
  • Maybe this answers your question https://stackoverflow.com/questions/51950533/fatal-python-error-init-sys-streams-cant-initialize-sys-standard-streams-attr – Aditya Jul 07 '20 at 17:09
  • @martineau yeah it shows both installs: ```Installed Pythons found by py Launcher for Windows -3.8-64 * -3.6-64``` but only 3.8 runs – Jack N Jul 07 '20 at 17:47
  • @Aditya thanks very much, that link helped sort the issue. I just needed to remove PYTHONHOME environment variable – Jack N Jul 07 '20 at 17:51
  • In that case it sounds like something is messed-up with the configuration of the two (or at least with v3.6). FWIW I use shebang lines like this `#!/usr/bin/env python3.6` in my own code on Windows. – martineau Jul 07 '20 at 17:54

1 Answers1

0

There was a problem with the environment variables. The PYTHONHOME environment variable was set to the python 3.8 directory. Once I deleted this variable, the problem was solved.

Jack N
  • 21
  • 2