Mayapy Interpreter Error

Mayapy Interpreter Error

bayareadeck
Enthusiast Enthusiast
322 Views
1 Reply
Message 1 of 2

Mayapy Interpreter Error

bayareadeck
Enthusiast
Enthusiast

Working in windows 10 command line mayapy interpreter.

Why am I getting this error ?

 

set PYTHONPATH=%PYTHONPATH%;C:\mayapybook\pylib
                 ^
SyntaxError: invalid syntax

0 Likes
323 Views
1 Reply
Reply (1)
Message 2 of 2

e_honda
Enthusiast
Enthusiast

Hi,

 

mayapy.exe is a Python interpreter.

 

The set command you wrote is a windows command.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1

*to be more precise, %ENVIRONMENTVARIABLE% is used in bat and cmd files.

  • If you call a variable value from a batch file, enclose the value with percent signs (%). For example, if your batch program creates an environment variable named BAUD, you can use the string associated with BAUD as a replaceable parameter by typing %baud% at the command prompt. 


 

if you wanna change environment variable, you should do it before you start mayapy.exe.

 

 

 

rem this line changes environment variables
set PYTHONPATH=%PYTHONPATH%;C:\mayapybook\pylib

rem this line starts mayapy.exe interpreter
mayapy.exe

 

 

 

 

Or, alternatively, you should change it in a inside your Python interpreter.

 

 

 

import os
import sys


append_path = r'C:\mayapybook\pylib'

# change environment variable
os.environ['PYTHONPATH'] = '%s;%s' % (os.environ['PYTHONPATH'], append_path)

# change sys.path
sys.path.append(append_path)

 

 

 

 

Hope it helps

0 Likes