minerllabs / minerl

MineRL Competition for Sample Efficient Reinforcement Learning - Python Package
http://minerl.io/docs/
Other
700 stars 154 forks source link

Cannot start multiple environments on windows (shutil permissions issue) #210

Open katja-hofmann opened 5 years ago

katja-hofmann commented 5 years ago

An exception is thrown when trying to create a second minerl environment instance on Windows. Tested with minerl 0.2.0 and 0.2.3

> python
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym
>>> import minerl
>>> env = gym.make('MineRLTreechop-v0')
>>>
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>>
>>> env2 = gym.make('MineRLTreechop-v0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\test\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 156, in make
    return registry.make(id, **kwargs)
  File "C:\Users\test\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 101, in make
    env = spec.make(**kwargs)
  File "C:\Users\test\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 73, in make
    env = cls(**_kwargs)
  File "C:\Program Files\Python36\lib\site-packages\minerl\env\core.py", line 133, in __init__
    self.instance = self._get_new_instance(port)
  File "C:\Program Files\Python36\lib\site-packages\minerl\env\core.py", line 155, in _get_new_instance
    instance.launch()
  File "C:\Program Files\Python36\lib\site-packages\minerl\env\malmo.py", line 438, in launch
    shutil.copytree(os.path.join(InstanceManager.MINECRAFT_DIR), self.minecraft_dir)
  File "C:\Program Files\Python36\lib\shutil.py", line 359, in copytree
    raise Error(errors)
shutil.Error: [('C:\\Program Files\\Python36\\lib\\site-packages\\minerl\\env\\Malmo\\Minecraft\\.gradle\\2.14\\taskArtifacts\\cache.properties.lock', 'C:\\Users\\test\\AppData\\Local\\Temp\\tmpc09k86if\\Minecraft\\.gradle\\2.14\\taskArtifacts\\cache.properties.lock', '[Errno 13] Permission denied')]
MadcowD commented 5 years ago

Oh I occasionally see this on windows; it has something to do with gradle locking it cache. Reinstalling minerl should clear this entirely, otherwise I need to investigate how to sanetize the current gradle stuff.

Try fulling uninstalling the package (run pip3 uninstall minerl many times) and then see if you run into this again.

If this doesn't work I can [ ] Make shutil copy ignore fiels with no permissions.

-Will

sixilli commented 5 years ago

I'm also experiencing this problem and can't run the environment at all. My error log is identical.

MadcowD commented 5 years ago

Investigating this currently

sixilli commented 5 years ago

Thanks! I've tried uninstalling and reinstalling multiple times. Sometimes a new error would pop up on the first run, but the second run this error would come back up again.

MadcowD commented 5 years ago

After some investigation, this is a race condition.

juliusfrost commented 4 years ago

It would amazing if this can be solved for the competition. Unfortunately, this limits environment usage to a single script per python environment.