Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

human mode: No such file or directory #3

Open
DougTrajano opened this issue Oct 15, 2021 · 4 comments
Open

human mode: No such file or directory #3

DougTrajano opened this issue Oct 15, 2021 · 4 comments

Comments

@DougTrajano
Copy link

Hey buddy. Firstly, congratulations on this project.

So, I had an issue with the human mode haha 馃槃

To play the game (human mode), run the following command:
$ flappy_bird_gym

Logs

PS C:\Users\trajano> flappy_bird_gym
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\programdata\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\flappy_bird_gym.exe\__main__.py", line 7, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\flappy_bird_gym\cli.py", line 79, in main
    flappy_bird_gym.original_game.main()
  File "c:\programdata\anaconda3\lib\site-packages\flappy_bird_gym\original_game.py", line 70, in main
    pygame.image.load(ASSETS_DIR + '/sprites/0.png').convert_alpha(),
FileNotFoundError: No such file or directory.

System Information

  • Python 3.8.11
  • Anaconda 4.10.3
@chokychou
Copy link

cd flappy_bird_gym/
It should then work.

@DougTrajano
Copy link
Author

I install it using pip install flappy-bird-gym.

@hbonnavaud
Copy link

same problem

@prabathbr
Copy link

prabathbr commented Feb 14, 2022

I am also getting the same issue with Human mode on Python 3.9.7 after installing with pip install flappy-bird-gym.
Random agent method is working fine with flappy_bird_gym --mode random.

I found a temporary solution by changing directory to E:\Miniconda3\envs\tf2\Lib\site-packages [This should be according to your installation, it is different from my setup] and running pip install flappy-bird-gym for there. Alternatively one can add this folder to $PATH system variable and it should work too [I haven't tried]. Then the Human mode works perfectly. So the issue is with the relative path to the pypi installed package directoy.

The actual issue is in original_game.py by directly mentioning ASSETS_DIR variable as ASSETS_DIR = "./flappy_bird_gym/assets"

Permanent Solution:

Replace ASSETS_DIR = "./flappy_bird_gym/assets" on original_game.py
with

import os
from pathlib import Path
_BASE_DIR = Path(os.path.dirname(os.path.realpath(__file__))).parent
ASSETS_DIR = str(_BASE_DIR / "flappy_bird_gym/assets")

Original Error:

C:\Windows\system32>flappy_bird_gym
Traceback (most recent call last):
  File "e:\Miniconda3\envs\tf2\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\Miniconda3\envs\tf2\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "e:\Miniconda3\envs\tf2\Scripts\flappy_bird_gym.exe\__main__.py", line 7, in <module>
  File "e:\Miniconda3\envs\tf2\lib\site-packages\flappy_bird_gym\cli.py", line 79, in main
    flappy_bird_gym.original_game.main()
  File "e:\Miniconda3\envs\tf2\lib\site-packages\flappy_bird_gym\original_game.py", line 70, in main
    pygame.image.load(ASSETS_DIR + '/sprites/0.png').convert_alpha(),
FileNotFoundError: No file './flappy_bird_gym/assets/sprites/0.png' found in working directory 'C:\Windows\system32'.

Temporary Solution:

E:\>cd E:\Miniconda3\envs\tf2\Lib\site-packages
E:\Miniconda3\envs\tf2\Lib\site-packages>flappy_bird_gym
E:\Miniconda3\envs\tf2\Lib\site-packages>

prabathbr added a commit to prabathbr/flappy-bird-gym that referenced this issue Feb 14, 2022
# Fix for issue : Talendar#3 by prabathbr (https://github.com/prabathbr/)
import os
from pathlib import Path
_BASE_DIR = Path(os.path.dirname(os.path.realpath(__file__))).parent
ASSETS_DIR = str(_BASE_DIR / "flappy_bird_gym/assets")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants