Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I installed both python 2.7 and 3.5, but python 3.5 does not work well

In terminal, I can run py -2 successfully. Nevertheless,

C:\Users\user>py -3
Fatal Python error: Py_Initialize: unable to load the file system codec
  File "C:\Python27\lib\encodings\__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

Current thread 0x00004570 (most recent call first):
like image 267
ming Avatar asked May 30 '16 16:05

ming


People also ask

How to fix installed Python3 but still Python 2 7 is used?

How To Fix Installed Python3 But Still Python 2.7 Is Used Error. Now when you execute the python command in a terminal, you will find it still uses the old version which is 2.7. To use the new Python version, you need to run python3 in the terminal. Type "help", "copyright", "credits" or "license" for more information.

How to install different version of Python on different computer?

When install Python version from 3.3 or newer a py.exe is placed in the Windows folder. This can be used to run all version 2 or 3 on that computer,can also choose pip to run from different version. So here running Python 2.7 and can install with pip using -m command.

How to install Python on Windows 10?

Install Python 3.7 & Python 3.9. 1 Go to python download page and click the related link to download. 2 After download, double click the installer to install it follow the wizard ( you can refer Install Python Linux And MacOS Version Tutorial ). 3 When the installation process completes successfully. ... More items...

What version of Python is installed on a Python launcher?

That’s an important point: by default, a 2.x version (if available) will be used by the launchers as the default Python even if a 3.x version is available. You can, however, change this behavior if you set a PY_PYTHON environment variable and set it to 3. So just to be clear, let’s say you have Python 3.4.1 and 2.7.7 installed.


2 Answers

Remove the "PYTHONHOME" environmental variable. (This resolved my problem when installed python27 x86 and python36 x64)

like image 128
R.Shabtai Avatar answered Nov 11 '22 17:11

R.Shabtai


You can try setting python path.

C:\Users\user>set PATH=C:\Program Files\Python 3.5;%PATH%
C:\Users\user>set PYTHONPATH=%PYTHONPATH%;C:\python_lib_path
C:\Users\user>python
like image 26
ajays20078 Avatar answered Nov 11 '22 17:11

ajays20078