ross-g/io_pdx_mesh

Multiple Maya 2023+ errors: PyMEL not found, shelf script incorrect

Opened this issue · 4 comments

  • OS: Windows 10
  • Modelling Application: Maya 2023
  • pymel: 1.3.1

After installing the Maya version into the Maya Script folder, and then creating a button on the shelf with the command to run the io_pdx_mesh plugin, I was presented with error 1, as stated in the title "No module named 'pymel'" on line x"
after attempting to then understand Python, managed to resolve it, but was presented with both errors 2 and 3, "Consider adding this directory to PATH", and "name error 'reload' is not defined".
I have personally resolved all 3, so below will be how I fixed them, won't be assisting others as I have limited knowledge in this field (doing in baby steps as well if anyone else lacks even less knowledge), just bringing this to light for anyone that might have got stuck like me, as well as for the developer of course.

Error 1:

  • Press the Windows key, type in "cmd" to open the Command Prompt, then type in "cd [DIRECTORY TO YOUR MAYAS VERSIONS BIN FOLDER]", so for me was cd C:\Program Files\Autodesk\Maya2023\bin
  • Now cmd is nestled in, time to figure out what version is installed by entering .\mayapy.exe -m pip list. You will then be presented with a list of things and proceeding with there version number. if "pymel" is not listed, well then there is your first problem. However, if it is, it MIGHT be out of date / different odd version that this project doesn't like, I don't know, I just told it to update to 1.3.1 (was running 2.7.1 or something)
  • To then now install a version (even if it says you already have one, I still did it just incase), run .\mayapy.exe -m pip install pymel
  • Then to upgrade just in case + if after reinstalling you were presented a message of a new version of pip, then run this .\mayapy.exe -m pip install --upgrade pip. But personally for me, for some reason that didn't work, so I forced it to install a version that apperntally worked via this video, which was mayapy -m pip install pymel==1.3.1
  • now that issue SHOULD be resolved, but you will most likely be presented with either or both issues 2 and 3

Error 2

  • This PATH error was a bi*ch and was supposed to have been auto-done via installing the pip / pymel, but personally, for some reason that did not work, so time to do this the hard way. So when it states the error of adding PATH to the directory, it usually prints said directory, copy it into a notepad for easy reference, it should be the same as mine, but if not, then it MIGHT not fix the issue, unknown. my path = C:\Users\[PC USERNAME]\AppData\Roaming\Python\Python39\Scripts
  • So, open up a fresh file explorer tab, and right-click on "This PC" on your left in the navigation panel (presuming you are a human and have it turned on, otherwise at the top, click view, left side, then click the dropdown and enable the navigation panel), and click on properties
  • It will take you to your PC's info tab, an for Windows 10, sadly, into its new 'control panel' settings application. scroll down to "Advance system settings", click on it and it will open another window
  • At the bottom of this new window will be "Environmental Variables...", click on it and it will open another window with a whole lot of variables that are connected to certain directorires.
  • it will be separated into the user-signed-in variables and the system's variables. We are looking in the system variables, scroll through and if you do not find the variable named "PATH", then click on "New...", otherwise, if there is, and it does not match the directory that was listed in the error before, an which I mentioned to store in a separate notepad file for now, then click on "Edit..."
  • if clicked on "New..." in the Variable name, type in "PATH", and in the Variable directory, press ";" (a semicolon) and THEN insert the directory stored before / said in the error. if in Edit, click Edit on the left side and insert ONLY the directory from before.
  • After that, click on "Okay" to get out of all the windows, an the PATH Error should be resolved.

Error 3

  • This is what I discovered was caused by the code this project creator provides to run the plugin, as it may need more commands, which is why this error report of "name error 'reload' is not defined" is presented. if running a different version to mine of Python, pip, pymel or whatever else is helping to cause this nightmare, refer to screenshot listed below and modify projects creators code / mine to resolve.
  • To begin with, if you just ran the code in the Maya's script editor, don't, it hurts my brain, if not, then skip this step, otherwise, continue. Now, just add it as a plugin / custom script to the shelf. To do so for those unknown, go to the top and go under Windows, then Settings/Preferences, then near the bottom, click on Shelf Editor. If you want it on a different shelf, select so on the left, else leave it on poly modelling / the last one you used or otherwise create a new shelf. Click the 3rd icon under "Shelf Contents" which is a plain with a + on top. Leave Icon name for now, you can customise this later, just change the "Tooltip" to io_pdx_mesh or something for now, so you know what it is when you highlight it in the Maya workspace. Then click on the "Command" Tab at the top, click the circle to change the code language being used from MEL to Python and remove the default print text from the box. Then insert the code mentioned in the next step
  • If you have this plugin script on the shelf, make sure you have it opened and replace the current code with mine / a modified version, refer to the screenshot below, otherwise if that doesn't work then you are doomed until the project creator / more insightful person responds. The code I used was:
    Line 1: import imp
    Line 2: import io_pdx_mesh;imp.reload(io_pdx_mesh)
  • Then at the top of the shelf editor, click on the "Shelves" tab, and at the bottom left, click on "Save All Shelves"

Screenshot of other Python Version Reload Code

ross-g commented

Thanks for the detailed report (and also for updating it once you found answers!) it's appreciated.

Yes from Maya 2023 onwards Autodesk decided to not include PyMEL by default. I have some in progress work to solve this automatically, but I should update the documentation here to reflect that from 2023 some additional steps are needed when installing.

Likewise, Python 3 is the default in more recent versions of Maya and I should update the install documentation (or just provide a pre-made shelf to install).

Thanks for the detailed report (and also for updating it once you found answers!) it's appreciated.

Yes from Maya 2023 onwards Autodesk decided to not include PyMEL by default. I have some in progress work to solve this automatically, but I should update the documentation here to reflect that from 2023 some additional steps are needed when installing.

Likewise, Python 3 is the default in more recent versions of Maya and I should update the install documentation (or just provide a pre-made shelf to install).

Well, that's the thing I don't understand, I have a script from some Japanese coder for proper circularise functions etc. His used Python and had the same PyMEL error issue, but when it said a fix was to make sure it was ticked in installation / re-install and actually tick it. I just downloaded the packages separately and it worked. So I was super confused when I saw it pop up again with this, and thus went to solution 2 of doing it via the console and other black magic listed above. my only presumption as to why they might of reacted differently in the end is that his was just 2 script py files that talked to each other for other functions. where as yours is, some form of complex folders and multiple scripts that I decided to not lose my brain cells in with another unknown language.

Any new about this issue? Having it with maya 2024 - partially solved by brute-installing pymel but its pretty obnoxious to use

There is no bug to fix here, you can blame Autodesk for bundling PyMEL with Maya for 10+ years resulting in it being heavily relied upon... then deciding one year they won't do that anymore and don't care if it breaks everyone's stuff.

It is covered in the Maya docs:
https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4