An issue setting up a development root directory (python for maya)

hey guys,
(just a little backstory for this, you can skip it and get straight to the scripting issue)
I’m a junior rigger and have been messing around with python for a little while…
as I decided it was best to start putting more effort into it I purchased the “practical maya programming with python” as I’ve heard a lot of people talking about it…
just received it today and was very excited, and I know it’s starting to get a little dated, especially in such a fast frowing topic, but anyway the first thing he’s saying to do there is setting up a root folder… and it’s just not working for me.

TL;DR - the issue itself:

I opened up a folder : “C:\mayapy\pylib” and I wanted to make it the development root.

the book suggests those steps (in the windows cmd):

set PYTHONPATH=%PYTHONPATH%;C:\mayapy\pylib
mayapy.exe

import sys
‘C:\mayapy\pylib’ in sys.path
True

import minspect #(the python file I created in the root folder)
minspect

now, problem is… after I type “mayapy.exe” it just prompts this message:
‘mayapy.exe’ is not recognized as an internal or external command, operable program or batch file.

also, when I tried just typing “import sys” it also gave me this error
(‘import’ is not recognized as an internal or external command, operable program or batch file.)

that might be kind of a noob question, but I’d really lovve some help with this.
thanks ahead guys

You should probably add this line before the PYTHONPATH line

set PATH=%PATH%;C:\Program Files\Autodesk\Maya2020\bin

Of course, make sure to use the correct folder for your computer.
For instance I’m using maya 2020, as you can see in that filepath.


What’s happening is the command prompt doesn’t know where to find mayapy.exe so it errors out.
Then (because it errored, and mayapy never started) the python commands you typed (ie import sys) also errored because they’re supposed to be run in mayapy, not cmd.

The line I gave you tells cmd a new place to look for programs to run, and that place contains mayapy.exe.

1 Like

yes, that was it, thank you so much! :slight_smile: