Example fails.
ytyp2 opened this issue · 3 comments
python = 3.7.6
rust = 1.40.0
MacOS 10.13.6
Steps
git clone https://github.com/MrRobb/gym-rs.git
cd gym-rs
virtualenv -p python3 develop
source develop/bin/activate
pip install -r requirements.txt
cargo run --example basic
Errors
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running target/debug/examples/basic
thread 'main' panicked at 'Error: import gym: PyErr { ptype: <class 'ModuleNotFoundError'>, pvalue: Some(ModuleNotFoundError("No module named 'gym'")), ptraceback: None }', src/libcore/result.rs:1165:5
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace.
I can't reproduce the error. I am using macOS 10.15.2, Rust 1.40 and Python 3.7.6.
Apparently, it can't find the gym
module. Make sure that the requirements are installed correctly and that pip --version
outputs "... (python 3.7)" since cpython (dependency) defaults to that.
macOS 10.15.2 works on me too.
macOS 10.13.6 does not work. macOS different c library?!
(develop) ➜ gym-rs git:(master) ✗ pip --version
pip 19.3.1 from /Users/ytyp2/gym-rs/develop/lib/python3.7/site-packages/pip (python 3.7)
(develop) ➜ gym-rs git:(master) ✗ pip list
Package Version
------------- --------
atari-py 0.2.6
box2d-py 2.3.8
cloudpickle 1.2.2
future 0.18.2
gym 0.15.4
imageio 2.6.1
numpy 1.18.1
opencv-python 4.1.2.30
Pillow 7.0.0
pip 19.3.1
pyglet 1.3.2
scipy 1.4.1
setuptools 45.0.0
six 1.13.0
wheel 0.33.6
(develop) ➜ gym-rs git:(master) ✗ RUST_BACKTRACE=1 cargo run --example basic
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/examples/basic`
thread 'main' panicked at 'Error: import gym: PyErr { ptype: <class 'ModuleNotFoundError'>, pvalue: Some(ModuleNotFoundError("No module named 'gym'")), ptraceback: None }', src/libcore/result.rs:1165:5
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:77
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1028
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:188
9: std::panicking::default_hook
at src/libstd/panicking.rs:205
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:464
11: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:373
12: rust_begin_unwind
at src/libstd/panicking.rs:302
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:139
14: core::result::unwrap_failed
at src/libcore/result.rs:1165
15: core::result::Result<T,E>::expect
at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/result.rs:960
16: <gym::GymClient as core::default::Default>::default
at src/lib.rs:340
17: basic::main
at examples/basic.rs:4
18: std::rt::lang_start::{{closure}}
at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/rt.rs:61
19: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:48
20: std::panicking::try::do_call
at src/libstd/panicking.rs:287
21: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:78
22: std::panicking::try
at src/libstd/panicking.rs:265
23: std::panic::catch_unwind
at src/libstd/panic.rs:396
24: std::rt::lang_start_internal
at src/libstd/rt.rs:47
25: std::rt::lang_start
at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/rt.rs:61
26: basic::main
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
Ran into the same issue when using a virtualenv. It's more of a general problem of the cpython crate rather than this one, you can resolve it by setting the PYTHONHOME
env var to the module path of the venv, e.g.:
PYTHONPATH=~/venv-py37/lib/python3.7/site-packages cargo run --example basic