google-deepmind / lab

A customisable 3D platform for agent-based AI research
Other
7.11k stars 1.37k forks source link

Python.h file not found error [macOS] #113

Closed YigitDemirag closed 5 years ago

YigitDemirag commented 5 years ago

I am following macOS instructions but I get the following error:

lab$ bazel run -c opt --define graphics=sdl //:python_random_agent -- --length=10000 --width=640 --height=480
INFO: Analysed target //:python_random_agent (0 packages loaded).
INFO: Found 1 target...
ERROR: /Users/x0r/Desktop/deepmind-lab-docker/lab/BUILD:957:1: C++ compilation of rule '//:deepmind_lab.so' failed (Exit 1)
python/dmlab_module.c:26:10: fatal error: 'Python.h' file not found
#include <Python.h>
         ^~~~~~~~~~
1 error generated.
Target //:python_random_agent failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.490s, Critical Path: 0.20s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

This is the output of python@2 info:

lab$ brew info python@2
python@2: stable 2.7.15 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@2/2.7.15_1 (4,704 files, 83.3MB) *
  Poured from bottle on 2018-11-23 at 00:56:33
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python@2.rb
==> Dependencies
Build: pkg-config ✘, sphinx-doc ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
    Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--HEAD
    Install HEAD version
==> Caveats
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 136,333 (30 days), 477,158 (90 days), 1,790,130 (365 days)
install_on_request: 30,598 (30 days), 89,721 (90 days), 348,749 (365 days)
build_error: 0 (30 days)

I only changed python path to path = "/usr/local/Cellar/python@2/2.7.15_1" and edited python.BUILD accordingly.

tkoeppe commented 5 years ago

What's the content of your python.BUILD and the Python-relevant entry in in WORKSPACE?

YigitDemirag commented 5 years ago

WORKSPACE:

new_local_repository(
    name = "python_system",
    build_file = "python.BUILD",
    path = "/usr/local/Cellar/python@2/2.7.15_1",
)

python.BUILD:

cc_library(
    name = "python",
    hdrs = glob([
        "python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/include/python2.7/*.h",
        "numpy/1.15.2/lib/python2.7/site-packages/numpy/core/include/numpy/*.h",
    ]),
    includes = [
        "python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/include/python2.7",
        "numpy/1.15.2/lib/python2.7/site-packages/numpy/core/include",
    ],
    visibility = ["//visibility:public"],
)
tkoeppe commented 5 years ago

Change the workspace path to path = "/usr/local/Cellar".

YigitDemirag commented 5 years ago

Thanks a lot. This solved Python.h not found error. I also needed to change numpy version at Python.BUILD file.

It seems working now.

INFO: Build completed successfully, 665 total actions
Failed to get __file__ attribute.
Starting random spring agent. Action spec: [{'max': 512, 'name': 'LOOK_LEFT_RIGHT_PIXELS_PER_FRAME', 'min': -512}, {'max': 512, 'name': 'LOOK_DOWN_UP_PIXELS_PER_FRAME', 'min': -512}, {'max': 1, 'name': 'STRAFE_LEFT_RIGHT', 'min': -1}, {'max': 1, 'name': 'MOVE_BACK_FORWARD', 'min': -1}, {'max': 1, 'name': 'FIRE', 'min': 0}, {'max': 1, 'name': 'JUMP', 'min': 0}, {'max': 1, 'name': 'CROUCH', 'min': 0}]
Finished after 10000 steps. Total reward received is 0.000000

Although the game screen was completely black during 10000 steps.

tkoeppe commented 5 years ago

Odd -- make sure your SDL2 installation is working? Do other SDL2 demo programs work? As I said, this mac stuff is extremely poorly tested, so anything that is different from this exact one machine I occasionally have is pretty much beyond me to debug. If you figure it out, I'd welcome patches or advice!

YigitDemirag commented 5 years ago

I can replicate successfully this to see if SDL2 is working. Regarding other SDL2 demo programs, bazel run -c opt --define graphics=sdl //:game -- --level_script lt_chasm also returns black screen. I will try to work on this further and write here if come up with something.

tkoeppe commented 5 years ago

Please reopen if you have new information, or even better, open a new issue for things unrelated to paths.