installing pyMel for multiple users on 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Autodesk chose not to include pyMel in the default installation of Maya 2024, but my client studios have numerous automation tools that rely on pymel, and I want to create a script that users/artists can run from Maya to handle the installation without having to open the command prompt.
I'm aware that the provided instructions are seemingly simple, but if you have lots of artists with widely varying skill sets working remotely, this can be a huge headache. I want to give them a single command or shelf button they can run from within maya, and give them a happy notice that it installed correctly and tell them to restart maya.
-----------------------------------------
from the Autodesk documentation:
https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4
- To install PyMEL, change directory to where mayapy is installed, and then run pip install pymel
- mayapy -m pip install pymel
or:
- mayapy -m pip install --user pymel
-----------------------------------------
to condense this into a python script, here is my methodology:
#Query installation directory in case artist installed on different drive or custom location
mayaLocation = mel.eval('getenv("MAYA_LOCATION")')
if not mayaLocation[-1]=='/':
mayaLocation+='/'
mayapy_location = mayaLocation+'bin'
lst = mayapy_location.split('/')
drive = lst[0]
lst = lst[1:len(lst)]
mayapy_location = drive +'\\' +os.path.join(*lst)
#Result = C:\Program Files\Autodesk\Maya2024\bin
cmd1 = "mayapy -m pip install pymel"
cmd2 = "mayapy -m pip install --user pymel"
import subprocess
try:
subprocess.run(cmd1)
except:
subprocess.run(cmd2)
Question: Will this work? I can't test it on my own machine because pymel is already installed. Do I need to include a "change directory" command to the subprocess prior to executing cmd1?
I tested this and it failed:
cmd = "cd " + mayapy_location
subprocess.run(cmd)