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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: __init__() should return None, not 'NoneType' in the step #4 in Mac installation #156

Closed
EduardoSantos7 opened this issue Apr 25, 2020 · 10 comments · Fixed by #313

Comments

@EduardoSantos7
Copy link

After following the 3 first steps I'm getting this error when I try to run step 4 python3 -m gfootball.play_game --action_set=full:

Traceback (most recent call last):
  File "/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/reysantos7/Desktop/googleFootballEnv/football/gfootball/play_game.py", line 70, in <module>
    app.run(main)
  File "/Users/reysantos7/Desktop/googleFootballEnv/football/football-env/lib/python3.7/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/Users/reysantos7/Desktop/googleFootballEnv/football/football-env/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "/Users/reysantos7/Desktop/googleFootballEnv/football/gfootball/play_game.py", line 50, in main
    'real_time': FLAGS.real_time,
  File "/Users/reysantos7/Desktop/googleFootballEnv/football/gfootball/env/config.py", line 81, in __init__
    self._game_config = libgame.GameConfig()
TypeError: __init__() should return None, not 'NoneType'

System Info:

image

@vi3itor
Copy link
Contributor

vi3itor commented Apr 26, 2020

I believe that Anaconda is causing your problems. Try searching for solutions like this one. You may try removing Anaconda's python from bash and use brew's installation.

@EduardoSantos7
Copy link
Author

I believe that Anaconda is causing your problems. Try searching for solutions like this one. You may try removing Anaconda's python from bash and use brew's installation.

But I installed with brew, also I removed Anaconda too and I tried to install it with brew again but the same error appears.

@vi3itor
Copy link
Contributor

vi3itor commented Apr 29, 2020

That's good that you could remove Anaconda, it will make easier to trace your problem. Make sure that you removed Anaconda from the Bash path, as explained here. Then restart the terminal, run brew doctor (you can provide output here). If you don't have any problems, go to football directory, pull the recent changes git pull, remove the directory with virtual environment (if you've created one) rm -r football-env and repeat the installation procedures. I highly recommend using a virtual environment.

@Harin329
Copy link

Harin329 commented Apr 29, 2020

If you really give up, a quick hack I used is to create your virtual env with the brew installed version of python (from usr/local/Cellar), so something like:

/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -m venv <env-name>

Your path env is probably still tied to Anaconda, but for someone that uses conda a lot and just wanted to try this out, it works.

@andrewchou
Copy link

I used conda on linux but had to use pip because of this issue on OSX

@henryboisdequin
Copy link

henryboisdequin commented Jul 24, 2020

I had the same problem.

Traceback (most recent call last):
  File "/Users/henryboisdequin/PycharmProjects/football-AI/train.py", line 3, in <module>
    env = football_env.create_environment(env_name='academy_empty_goal', representation='pixels', render=True)
  File "/Users/henryboisdequin/PycharmProjects/football-AI/football-env/lib/python3.7/site-packages/gfootball/env/__init__.py", line 182, in create_environment
    scenario_config = config.Config({'level': env_name}).ScenarioConfig()
  File "/Users/henryboisdequin/PycharmProjects/football-AI/football-env/lib/python3.7/site-packages/gfootball/env/config.py", line 78, in __init__
    self._game_config = libgame.GameConfig()
TypeError: __init__() should return None, not 'NoneType'

I have tried the previous solutions but unfortunately, they haven't worked. I'm on OSX. Any help would be appreciated.

This was my code:

import gfootball.env as football_env

env = football_env.create_environment(env_name='academy_empty_goal', representation='pixels', render=True)

state = env.reset()

@vi3itor
Copy link
Contributor

vi3itor commented Jul 24, 2020

I need more information to help you with it. What installation of python are you using: brew, conda, or anything else?

Did you follow the guide to install dependencies on the main page? If you did it recently and got Python 3.8 from brew, then you need to upgrade boost-python3 as I explained here yesterday. And more likely to install old sdl for pygame (check the comment for more details).
The other point to note: if python3 is not linked to a brew installation in your system, to create a virtual environment with a brew distributive of it you'll need to do something like:

/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -m venv football-env

depending on what version of Python 3.8 you have installed. Just do brew upgrade python3 to have the latest one.
If you have any errors with installation, please attach log here.

@vi3itor
Copy link
Contributor

vi3itor commented Jul 24, 2020

Even a better way to create a virtual environment with brew version of python:

$(brew --prefix python3)/bin/python3.8 -m venv football-env

@henryboisdequin
Copy link

Thanks, vi3itor! Everything works now.

@mikhail-vlasenko
Copy link

For me, the article about keeping conda away from brew installation didn't help
However, when I typed conda deactivate, deactivating the base environment, and then pip3 install gfootball in a new venv, everything started to work fine

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

Successfully merging a pull request may close this issue.

6 participants