Python error message

1,581 views
Skip to first unread message

Steve Davy

unread,
Dec 9, 2021, 3:49:38 PM12/9/21
to Maya Group
I'm trying to use Morgan Loomis' excellent Toolbox script browser script with Maya 2022, but when running the snippet of MEL to load it getting this error message:

# Error: line 1: SyntaxError: file C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py line 142: invalid syntax #

It's not clear to me whether this is a code error now present in his script due to changes in Python itself -- doesn't look like this error is pointing at that though?

This script works fine in Maya 2020. It's been an invaluable tool for me for years now and I would love to get it working in 2022. Anyone got any pointers as to what's going on?

Morgan Loomis

unread,
Dec 9, 2021, 7:51:37 PM12/9/21
to maya_he3d
Sorry Steve, I haven't gotten around to updating these to python3 for maya 2022. I'm hoping to do it over the holidays. Apologies!

--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/BYAPR07MB58613915ECC80C4960D7428FDD709%40BYAPR07MB5861.namprd07.prod.outlook.com.

Armin

unread,
Dec 10, 2021, 11:20:14 AM12/10/21
to maya...@googlegroups.com
You could try starting maya 2022 with python2.
"maya.exe -pythonver 2"

Steve Davy

unread,
Dec 10, 2021, 7:04:19 PM12/10/21
to maya...@googlegroups.com
Ah, so it is a Python version issue!

Glad to know you're planning on updating it Morgan -- it's an awesome tool. Thanks for the reply and I'll look out for the latest version.


From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of Morgan Loomis <morgan...@gmail.com>
Sent: Thursday, December 9, 2021 4:51 PM
To: maya_he3d <maya...@googlegroups.com>
Subject: Re: [maya_he3d] Python error message
 

Steve Davy

unread,
Dec 13, 2021, 2:48:43 PM12/13/21
to maya...@googlegroups.com
Thanks, actually this worked perfectly!


From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of Armin <temp.op...@gmail.com>
Sent: Friday, December 10, 2021 8:20 AM
To: maya...@googlegroups.com <maya...@googlegroups.com>

Subject: Re: [maya_he3d] Python error message

Steve Davy

unread,
Dec 13, 2021, 2:49:24 PM12/13/21
to maya...@googlegroups.com
Detailed info on how to do this here:

I highly recommend starting to look at moving to Python 3. I've written a guide for auto-converting your Maya Python 2 code to Python 3 with considerations for cross-compatibility between the two versions. If you're not quite ready to port your code and want to start trying out Maya 2022 without having to worry about Python 3, I thought this post might help you out.



From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of Armin <temp.op...@gmail.com>
Sent: Friday, December 10, 2021 8:20 AM
To: maya...@googlegroups.com <maya...@googlegroups.com>
Subject: Re: [maya_he3d] Python error message
 

stephen mann

unread,
Dec 13, 2021, 8:44:36 PM12/13/21
to maya...@googlegroups.com
From what ive seen the majority of python code that has conversion from py2 to py3 issues comes from 
 Print and reload 

 print it now a callable function so all print statements need to be in used that way .. 
 Ie:   print “ hey. Its python2” 
 Now needs to be 
print (“this is python 3”) 

The other common issue is reload which now needs to be imported first 

from importLib import reload 
( or at least thats how i do it :) ) 

Hth 

-=s

On Dec 13, 2021, at 2:49 PM, Steve Davy <stevi...@hotmail.com> wrote:



Morgan Loomis

unread,
Jan 2, 2022, 12:56:12 AM1/2/22
to maya_he3d
Hey Steve, I've just finally updated my github repository to be python3 compatible, though I haven't fully tested everything yet. Give it a go and let me know if you ever run into anymore issues.

Happy New Year everyone.

-Morgan

On Fri, Dec 10, 2021 at 9:49 AM Steve Davy <stevi...@hotmail.com> wrote:
--

Steve Davy

unread,
Jan 6, 2022, 1:53:09 PM1/6/22
to maya...@googlegroups.com
Great, thanks Morgan!

Pointing Maya to Python 2 was actually a really easy workaround, but I'll grab your updated version ASAP.


From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of Morgan Loomis <morgan...@gmail.com>
Sent: Saturday, January 1, 2022 9:55 PM
To: maya_he3d <maya...@googlegroups.com>

Subject: Re: [maya_he3d] Python error message

Steve Davy

unread,
Aug 2, 2022, 8:04:58 PM8/2/22
to maya...@googlegroups.com
Hey Morgan,

Just upgraded to Maya 2023 and am now getting a line 1 invalid syntax error when trying to run

python("import ml_toolbox;ml_toolbox.main()");

Normally I use the userSetup.mel approach anyway, but I get this error even when running the code from the script ed.

Any idea what the problem is?

Thanks!

From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of Morgan Loomis <morgan...@gmail.com>
Sent: Saturday, January 1, 2022 9:55 PM
To: maya_he3d <maya...@googlegroups.com>
Subject: Re: [maya_he3d] Python error message
 

Morgan Loomis

unread,
Aug 2, 2022, 8:26:09 PM8/2/22
to maya...@googlegroups.com
make sure you have the latest code from the repository, I updated it all to python3 recently, and send me the error if it persists. https://github.com/morganloomis/ml_tools

Steve Davy

unread,
Aug 4, 2022, 4:03:59 PM8/4/22
to maya...@googlegroups.com
Thanks, downloading the latest version fixed it although as usual I had to spend 20 minutes trying to figure out which scripts folder Maya was picking up from.

I really will never understand why it's necessary for Maya to have THREE scripts folder locations. 😕


Sent: Tuesday, August 2, 2022 5:25 PM
To: maya...@googlegroups.com <maya...@googlegroups.com>

stephenkmann

unread,
Aug 4, 2022, 4:54:55 PM8/4/22
to maya...@googlegroups.com
You can have as many script folders as you like..  I actually appreciate that you can just add a path to the env and get what you want. Especially with project specific scripts or version specific scripts.

With that said. if you are trying to find where a mel or python is coming from you can run 

mel:    whatIs  nameOfMelScript
python : help (name_of_python)

hth
-=s



--

Steve Davy

unread,
Aug 8, 2022, 2:43:40 PM8/8/22
to maya...@googlegroups.com
Hey Steve,

Yeah, I know you can query the script path, and I'm sure for people heavily invested in scripting there's all sorts of advantages to multiple locations.

However, for us mere mortals who just want to get the job done quickly, it's a real pain in the ass to have the three default locations to deal with, all in strangely similar but different parts of the folder hierarchy.

And, if as you say you can create as many as you want, it begs the question why any of them are created automatically at all. Just another example of sloppy legacy stuff that gets installed with Maya IMO.

From: maya...@googlegroups.com <maya...@googlegroups.com> on behalf of stephenkmann <stephe...@gmail.com>
Sent: Thursday, August 4, 2022 1:54 PM

stephenkmann

unread,
Aug 8, 2022, 7:41:07 PM8/8/22
to maya...@googlegroups.com
the one in user/Maya/scripts  is there for all installations of Maya   ( all versions) 
the one(s) in user/Maya/2020/scripts or user/Maya/2021/scripts/ or  user/Maya/2022/scripts/ are per installation version ( not all scripts work in all versions of Maya ,, as changes to base code happens)
the one in projects/[ project name]/ will only get sourced during the setting of the project For that project.  So it's a great way to globally share scripts with everyone on a project. 

I'm not sure where the pain lives..   Just drop it in user/maya/scripts/         that will work 99% of the time. 

Unless it's for a specific version of Maya.. then  user/maya/[version#]/scripts/

I wouldn't recommend messing with the ones in program files / autodesk / Maya / version etc.  ( there is no need to )

hth

-=s



Reply all
Reply to author
Forward
0 new messages