pythonanacondazipline

Can't change Anaconda env default python version


I'm setting up my Anaconda enviroment recently,I have two enviroments:

  1. python3.7.6(which is same as Anaconda's python version).
  2. python3.5.6 which is suited for Zipline

I checked the zipline eviroment's python version,it shows python3.5.6,BUT when I input "zipline" it showed this,I've added both python35 & python37 to my enviroment PATH.

(zip35) C:\Users\th>zipline

Fatal Python error: Py_Initialize: can't initialize sys standard streams

Traceback (most recent call last):

  File "C:\Python37\Lib\io.py", line 52, in <module>

  File "C:\Python37\Lib\abc.py", line 147

    print(f"Class: {cls.__module__}.{cls.__qualname__}", file=file)

                                                      ^
SyntaxError: invalid syntax

Could anyone help me out?


Solution

  • You have messed up your set up with this:

    I've added both python35 & python37 to my enviroment PATH

    Which results in a weird mix between your anaconda env and the version you have at C:\Python37

    From your question, I gather the following:

    1. You have anaconda installed with python 3.7
    2. You have created an environment zip35 which uses python version 3.5
    3. You have installed a seperate python 3.7 at C:\Python37
    4. You have manually added stuff to PATH

    To fix, do the following:

    1. Uninstall the C:\Python37, there is no valid reason to have that next to your anaconda installation. It just creates confusion
    2. Remove all custom modifications of PATH
    3. If you want to use python 3.5 and zipline, then use the zip35 environment, if you want python 3.7 then use the base env of anaconda or create a seperate one.