I am using Ubuntu 18.04, Python 3.7.2 and mujoco (1.50). I have installed mujoco and gym with all the dependencies employing commands
pip3 install <package> --user
almost everything but import mujoco_py works. I can run the examples cartPole and pacman but when i try to import mujoco_py i got the following error:
PermissionError Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/lockfile-0.12.2-py3.7.egg/lockfile/linklockfile.py in acquire(self, timeout)
18 try:
---> 19 open(self.unique_name, "wb").close()
20 except IOError:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.7/site-packages/mujoco_py-1.50.1.68-py3.7.egg/mujoco_py/generated/dryanguasr-G752VSK-79228080.4720-9208174717403130829'
During handling of the above exception, another exception occurred:
LockFailed Traceback (most recent call last)
<ipython-input-5-85c6ae7fd0aa> in <module>
----> 1 import mujoco_py
/usr/local/lib/python3.7/site-packages/mujoco_py-1.50.1.68-py3.7.egg/mujoco_py/__init__.py in <module>
1 #!/usr/bin/env python
2 import os
----> 3 from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
4 from mujoco_py.generated import const
5 from mujoco_py.mjrenderpool import MjRenderPool
/usr/local/lib/python3.7/site-packages/mujoco_py-1.50.1.68-py3.7.egg/mujoco_py/builder.py in <module>
501
502 mjpro_path, key_path = discover_mujoco()
--> 503 cymj = load_cython_ext(mjpro_path)
504
505
/usr/local/lib/python3.7/site-packages/mujoco_py-1.50.1.68-py3.7.egg/mujoco_py/builder.py in load_cython_ext(mjpro_path)
87 lockpath = os.path.join(os.path.dirname(cext_so_path), 'mujocopy-buildlock')
88
---> 89 with LockFile(lockpath):
90 mod = None
91 force_rebuild = os.environ.get('MUJOCO_PY_FORCE_REBUILD')
/usr/local/lib/python3.7/site-packages/lockfile-0.12.2-py3.7.egg/lockfile/__init__.py in __enter__(self)
195 Context manager support.
196 """
--> 197 self.acquire()
198 return self
199
/usr/local/lib/python3.7/site-packages/lockfile-0.12.2-py3.7.egg/lockfile/linklockfile.py in acquire(self, timeout)
19 open(self.unique_name, "wb").close()
20 except IOError:
---> 21 raise LockFailed("failed to create %s" % self.unique_name)
22
23 timeout = timeout if timeout is not None else self.timeout
LockFailed: failed to create /usr/local/lib/python3.7/site-packages/mujoco_py-1.50.1.68-py3.7.egg/mujoco_py/generated/dryanguasr-G752VSK-79228080.4720-9208174717403130829
Apparently it is a permissions error but i do not know how to solve it. Sorry if its a very simple issue but i have been stocked here for a while and do not find solution. I tried uninstalling and reinstalling Mujoco without cache but it did not work.
I'm getting the same issue.
This started happening to me recently as well. A simple fix is to just remove the build lock. If you're using a virtual environment, something like: path-to-venv/lib/pythonX.X/site-packages/mujoco_py/generated/mujocopy-buildlock.lock.
The problem was the python version... the mujoco dependencies aparently are not compatible with the 3.7 versions, so i changed to the 3.6 version (made additional troubleshooting related to the OpenGL implementation with the graphics card) and it worked.
I was having the same issue when using this in a singularity img in the server. It was working fine locally but displaying error when I try import mujoco_py in the server.
I fixed it by installing mujoco-py-1.50.1.56 instead of mujoco-py-1.50.1.68.
>> pip3 install mujoco-py==1.50.1.56
1.50.1.56 version does not require lockfile package.
permission denied----> the simplest way to slove is "sudo chmod 777 ath-to-venv/lib/pythonX.X/site-packages/mujoco_py/generated/"
I solved the problem using the same solution as NoobHua.
I received the following error:
PermissionError: [Errno 13] Permission denied: b'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mujoco_py/generated/mujocopy-buildlock'
I solved as follows:
cd /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mujoco_py
sudo chmod -R 777 ./ (change permission of all files in all subfolders recursively)
I solved the problem using the same solution as NoobHua.
I received the following error:
PermissionError: [Errno 13] Permission denied: b'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mujoco_py/generated/mujocopy-buildlock'
I solved as follows:
cd /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mujoco_py
sudo chmod -R 777 ./ (change permission of all files in all subfolders recursively)
It works! Thanks a lot.
Most helpful comment
permission denied----> the simplest way to slove is "sudo chmod 777 ath-to-venv/lib/pythonX.X/site-packages/mujoco_py/generated/"