Setting the compiler to Python 3.x

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
dijerydack
Posts: 7
Joined: Sat May 25, 2013 11:02 am

Setting the compiler to Python 3.x

Post by dijerydack »

In compiler options / command line I have put : c:\python33\python.exe "$fn" (I dont know what "$fn" is, it was there already so I left it.) That is my python directory. however Python loads and crashes immediately and I get this error :

Using document type compiler options....

Fatal Python error: Py_Initialize: unable to load the file system codec
File "C:\Users\Jack\AppData\Roaming\Xidicone\Zeus\zScript\PyLib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax


What am I doing wrong?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

You have done everything correctly but what has happened is the newer Python has picked up the older Python library that comes with Zeus.

I'll have to do some testing at this end to see how to fix this.

But in the mean time go to this folder:

Code: Select all

C:\Users\Jack\AppData\Roaming\Xidicone\Zeus\zScript\
and rename PyLib to PyLib-Old

I'm hoping that will stop the new Python finding the old library so it will then use it's version of the library files.

Cheers Jussi
dijerydack
Posts: 7
Joined: Sat May 25, 2013 11:02 am

Post by dijerydack »

That seems to work. Thanks.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

To fix this properly you can do the following.

Firstly put back the Zeus PyLib folder which will break the compiler option.

Now for some further information on how the compile works.

To compile (syntax check) a Python file from inside Zeus this zpython.cmd batch file (found in the Zeus install folder) is used:

Code: Select all

@echo off
REM Move to the file's directory
cd %2

REM Remove the double quotes from the file name argument
set file_name=%1
set file_name=%file_name:"=%

REM Run a syntax check on the file provided
call pythonc.exe -c "compile(open('%file_name%').read(), '%file_name%', 'exec')"
This batch file is run via the Compiler options found in the Python document type using this command line:

Code: Select all

zpython.cmd "$f" "$fdd"
The "$f" and "$fdd" above equate to the file name and file drive directory of the currently active file and are passed to the batch file as arguments.

You will notice that the pythonc.exe is being used to compile the file. This executable is nothing more than the Python 2.7.2 version that comes with Zeus.

In your case you want to run the latest Python 3.x so just change the batch file to use the correct Python version as follows:

Code: Select all

call C:\Python33\python.exe -c "compile(open('%file_name%').read(), '%file_name%', 'exec')"
And make sure the Python Compiler command line is set to this:

Code: Select all

zpython.cmd "$f" "$fdd"
But after doing this when you compile a file you will get the same error that you reported earlier:

Code: Select all

Fatal Python error: Py_Initialize: unable to load the file system codec 
File "C:\Users\Jack\AppData\Roaming\Xidicone\Zeus\zScript\PyLib\encodings\__init__.py", line 123 
raise CodecRegistryError,\ 
^ 
SyntaxError: invalid syntax

This is because Zeus has set the PYTHONPATH environment variable to point to this folder:

Code: Select all

C:\Users\Jack\AppData\Roaming\Xidicone\Zeus\zScript\PyLib\
But this folder contains the 2.72 version of the library not the required 3.3 version.

To fix this just set the PYTHONPATH environment variable by hand as follows:
  1. Start Run, Control Panel menu
  2. System, Advance System Settings
  3. Environment Variables
Add the environment PYTHONPATH variable with a value of:

Code: Select all

C:\Python33\Lib;
Now if you restart Zeus and recompile the file, this time the Python executable will find the correct version of the library files :)

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Another thing you should do is make sure the C:\Python33 folder is in the system PATH environment variable.

Use the Control Panel, Environment Variables (as described earlier) to edit the PATH environment variable, adding this folder to that variable:

Code: Select all

C:\Python33
Cheers Jussi
Post Reply