edbeeching / godot_rl_agents

An Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents
MIT License
942 stars 69 forks source link

Specify to create a Python 3.10 venv, with example #112

Closed audreyfeldroy closed 10 months ago

audreyfeldroy commented 1 year ago

Hey, thank you so much for Godot RL Agents!

While going through the Quickstart Guide, I encountered an error due to using a Python 3.11 virtualenv:

gdrl --env=gdrl --env_path=examples/godot_rl_JumperHard/bin/JumperHard.x86_64 --viz
Error:  No module named 'ray'
Error:  No module named 'sample_factory'

To overcome this issue, I created a Python 3.10 virtualenv and successfully bypassed those errors. I have documented this solution in my pull request.

If it is desired to support earlier Python versions, I am more than willing to update this pull request and test with different Python versions. However, I thought it would be best to start with this solution.

Feel free to make any modifications to this message or close the pull request if you prefer to keep it as it is. My intention is simply to assist others in avoiding the same errors. Thank you! 😄

audreyfeldroy commented 1 year ago

Hold off on merging this for now, I think. I'm actually running into some errors getting training to work on Python 3.10 (I'm on macOS Ventura 13.4). So far I've also done:

brew install git-lfs
pip install sample-factory

I'm currently getting this on 3.10 and seeing if downgrading to 3.9 will resolve it:

gdrl --env=gdrl --env_path=examples/godot_rl_JumperHard/bin/JumperHard.x86_64 --viz
Traceback (most recent call last):
  File "/Users/a/.pyenv/versions/godot_rl_agents-env-3.10/bin/gdrl", line 8, in <module>
    sys.exit(main())
  File "/Users/a/.pyenv/versions/3.10/envs/godot_rl_agents-env-3.10/lib/python3.9/site-packages/godot_rl/main.py", line 91, in main
    training_function(args, extras)
  File "/Users/a/.pyenv/versions/3.10/envs/godot_rl_agents-env-3.10/lib/python3.9/site-packages/godot_rl/wrappers/stable_baselines_wrapper.py", line 74, in stable_baselines_training
    env = StableBaselinesGodotEnv(env_path=args.env_path, show_window=args.viz, speedup=args.speedup)
  File "/Users/a/.pyenv/versions/3.10/envs/godot_rl_agents-env-3.10/lib/python3.9/site-packages/godot_rl/wrappers/stable_baselines_wrapper.py", line 12, in __init__
    self.env = GodotEnv(env_path=env_path, convert_action_space=True, **kwargs)
  File "/Users/a/.pyenv/versions/3.10/envs/godot_rl_agents-env-3.10/lib/python3.9/site-packages/godot_rl/core/godot_env.py", line 40, in __init__
    self.check_platform(env_path)
  File "/Users/a/.pyenv/versions/3.10/envs/godot_rl_agents-env-3.10/lib/python3.9/site-packages/godot_rl/core/godot_env.py", line 85, in check_platform
    assert os.path.exists(filename)
AssertionError
audreyfeldroy commented 1 year ago

In a Python 3.9 virtualenv I got this:

gdrl --env=gdrl --env_path=examples/godot_rl_JumperHard/bin/JumperHard.x86_64 --viz
Traceback (most recent call last):
  File "/Users/a/.pyenv/versions/godot_rl_agents-env-3.9/bin/gdrl", line 8, in <module>
    sys.exit(main())
  File "/Users/a/.pyenv/versions/3.9.16/envs/godot_rl_agents-env-3.9/lib/python3.9/site-packages/godot_rl/main.py", line 91, in main
    training_function(args, extras)
  File "/Users/a/.pyenv/versions/3.9.16/envs/godot_rl_agents-env-3.9/lib/python3.9/site-packages/godot_rl/wrappers/stable_baselines_wrapper.py", line 74, in stable_baselines_training
    env = StableBaselinesGodotEnv(env_path=args.env_path, show_window=args.viz, speedup=args.speedup)
  File "/Users/a/.pyenv/versions/3.9.16/envs/godot_rl_agents-env-3.9/lib/python3.9/site-packages/godot_rl/wrappers/stable_baselines_wrapper.py", line 12, in __init__
    self.env = GodotEnv(env_path=env_path, convert_action_space=True, **kwargs)
  File "/Users/a/.pyenv/versions/3.9.16/envs/godot_rl_agents-env-3.9/lib/python3.9/site-packages/godot_rl/core/godot_env.py", line 40, in __init__
    self.check_platform(env_path)
  File "/Users/a/.pyenv/versions/3.9.16/envs/godot_rl_agents-env-3.9/lib/python3.9/site-packages/godot_rl/core/godot_env.py", line 85, in check_platform
    assert os.path.exists(filename)
AssertionError

I'll try 3.8 next 🙂

edbeeching commented 1 year ago

Hi @audreyfeldroy , did you make any progress? The repo isn't very well tested on Mac so it would be great to know if you got things working.

audreyfeldroy commented 1 year ago

Trying it on Python 3.8 gave me the same error, and I realized the Python version was probably not the issue there. I'll try it on Windows or Linux and see if I can get it working, then try and look into what's happening on Mac once I understand things better. 🙂

Ivan-267 commented 1 year ago

Hello,

While I'm not able to check on Mac OS so I'm not sure if this is correct, here is a potential cause for the issue, the download example from the hub has these executable files on my Windows computer: image

However gdrl on Mac is looking for "JumperHard.app", and the error points to the file not being found.

@audreyfeldroy If you have Godot installed, perhaps you could try: 1) Downloading the example either using the same command from tutorial gdrl.env_from_hub -r edbeeching/godot_rl_JumperHard or by downloading this repository https://github.com/edbeeching/godot_rl_agents_examples

2) Opening the example project ("Import project") from Godot: image

3) Typing gdrl in the console without the other arguments. image

4) Pressing the "Play" button in Godot image

edbeeching commented 1 year ago

Hi @audreyfeldroy, did you manage to get things working? Ok if I close this PR?

Let me know if you need help with anything.