FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

Not table to install FInRL locally: Failed to build box2d-py

Open emcwin opened this issue 2 years ago • 7 comments

Describe the bug A clear and concise description of what the bug is.

Running the command pip install git+https://github.com/AI4Finance-Foundation/FinRL.git

To Reproduce Steps to reproduce the behavior:

  1. Go to '...' command prompt and get into a python enviornment
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior FinRL installed Screenshot 2023-11-24 165158

Screenshots If applicable, add screenshots to help explai Screenshot 2023-11-24 165158 n your problem.

Desktop (please complete the following information):

  • OS: Windows

emcwin avatar Nov 24 '23 21:11 emcwin

pls git clone

zhumingpassional avatar Dec 02 '23 01:12 zhumingpassional

will git clone get around the problem of installing box2d on windows? seems like opengym only works on linux and mac?

CoderM8n avatar Dec 17 '23 08:12 CoderM8n

I tried Ubuntu 22.04, Win10, Docker for this project; Pulling git is also not possible, as the error report shows that the pulled Python code is incorrect; Building a virtual environment based on the checklist is also not feasible. It can't be installed at all, whether it's anaconda or py3.7, py3.8, py3.9; Conda or pip, etc. (Even after cloning, it doesn't work) This has wasted a week of my time.

Change to another project, don't waste time here

wanghaora avatar Dec 28 '23 08:12 wanghaora

box2d is not necessary.

it works if using git clone

zhumingpassional avatar Dec 28 '23 09:12 zhumingpassional

I had been stuck with this error for 3 weeks, but finally found a way. Here are the steps that I followed.

  1. Pull anaconda docker image using "docker pull continuumio/miniconda3:23.10.0-1".
  2. Get insitde the container using "docker run --rm -it continuumio/miniconda3:23.10.0-1 /bin/bash"
  3. Create a conda environment once you are inside the container using "conda create -n finrl-env python=3.10"
  4. Install required system packages using "apt-get update && apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev libgl1-mesa-glx swig" as mentioned in https://finrl.readthedocs.io/en/latest/start/installation.html#step-2-install-openai
  5. Apart from the system packages mentioned in the documentation, install g++ too to build box2d successfully. Use the command "apt-get install g++".
  6. Finally, install finrl package using "pip install git+https://github.com/AI4Finance-Foundation/FinRL.git" as mentioned in the official documentation (https://finrl.readthedocs.io/en/latest/start/installation.html#step-3-install-finrl).

Now, you should be able to import finrl successfully using python.

Details: The following was the error that I had been facing.

Building wheels for collected packages: finrl, elegantrl, box2d-py Building wheel for finrl (pyproject.toml) ... done Created wheel for finrl: filename=finrl-0.3.6-py3-none-any.whl size=4670835 sha256=818c0ceadaed5255bcf7024241293a6520cd7690516ead78f635cbdb25e6179a Stored in directory: /tmp/pip-ephem-wheel-cache-unccja2w/wheels/f3/4d/1b/20f374fc224a02a8b169147765b088ce91e0f9c3c72d259bac Building wheel for elegantrl (setup.py) ... done Created wheel for elegantrl: filename=elegantrl-0.3.6-py3-none-any.whl size=197330 sha256=0dd08e0d48ab02c6815f519ee3b684f130f4917756ceb564dc1c11c0315dca9e Stored in directory: /tmp/pip-ephem-wheel-cache-unccja2w/wheels/c0/51/a5/b05f165548221bc570f7223babd33e2992fa873cdcebe2d229 Building wheel for box2d-py (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [39 lines of output] Using setuptools (version 68.2.2). running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-310 creating build/lib.linux-x86_64-cpython-310/Box2D copying library/Box2D/Box2D.py -> build/lib.linux-x86_64-cpython-310/Box2D copying library/Box2D/init.py -> build/lib.linux-x86_64-cpython-310/Box2D creating build/lib.linux-x86_64-cpython-310/Box2D/b2 copying library/Box2D/b2/init.py -> build/lib.linux-x86_64-cpython-310/Box2D/b2 running build_ext building 'Box2D._Box2D' extension swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp swig -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library/Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i Box2D/Common/b2Math.h:67: Warning 302: Identifier 'b2Vec2' redefined by %extend (ignored), Box2D/Box2D_math.i:47: Warning 302: %extend definition of 'b2Vec2'. Box2D/Common/b2Math.h:158: Warning 302: Identifier 'b2Vec3' redefined by %extend (ignored), Box2D/Box2D_math.i:168: Warning 302: %extend definition of 'b2Vec3'. Box2D/Common/b2Math.h:197: Warning 302: Identifier 'b2Mat22' redefined by %extend (ignored), Box2D/Box2D_math.i:301: Warning 302: %extend definition of 'b2Mat22'. Box2D/Common/b2Math.h:271: Warning 302: Identifier 'b2Mat33' redefined by %extend (ignored), Box2D/Box2D_math.i:372: Warning 302: %extend definition of 'b2Mat33'. Box2D/Collision/b2DynamicTree.h:44: Warning 312: Nested union not currently supported (ignored). Box2D/Common/b2Settings.h:144: Warning 506: Can't wrap varargs with keyword arguments enabled Box2D/Common/b2Math.h:91: Warning 509: Overloaded method b2Vec2::operator ()(int32) effectively ignored, Box2D/Common/b2Math.h:85: Warning 509: as it is shadowed by b2Vec2::operator ()(int32) const. creating build/temp.linux-x86_64-cpython-310 creating build/temp.linux-x86_64-cpython-310/Box2D creating build/temp.linux-x86_64-cpython-310/Box2D/Collision creating build/temp.linux-x86_64-cpython-310/Box2D/Collision/Shapes creating build/temp.linux-x86_64-cpython-310/Box2D/Common creating build/temp.linux-x86_64-cpython-310/Box2D/Dynamics creating build/temp.linux-x86_64-cpython-310/Box2D/Dynamics/Contacts creating build/temp.linux-x86_64-cpython-310/Box2D/Dynamics/Joints gcc -pthread -B /opt/conda/envs/finrl-env/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/envs/finrl-env/include -fPIC -O2 -isystem /opt/conda/envs/finrl-env/include -fPIC -I/opt/conda/envs/finrl-env/include/python3.10 -c Box2D/Box2D_wrap.cpp -o build/temp.linux-x86_64-cpython-310/Box2D/Box2D_wrap.o -I. -Wno-unused gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for box2d-py Running setup.py clean for box2d-py Successfully built finrl elegantrl Failed to build box2d-py ERROR: Could not build wheels for box2d-py, which is required to install pyproject.toml-based

The error line highlighted in the above error trace (gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory) helped me to understand the error. Afterwards, when I searched it on the internet, I found https://askubuntu.com/questions/637014/gcc-error-trying-to-exec-cc1plus-execvp-no-such-file-or-directory. Installing g++ as per the forum comments resolved the issue with box2d.

I hope it helps

ashokcse135 avatar Jan 07 '24 06:01 ashokcse135

so running running on Windows 10 directly via Anaconda Python Terminal not possible? -Essentially your saying it can only run on linux OS (Either on Linux docker container or Linux OS directly?)

If windows direct is support please explain how to get round the Failed to build box2d-py ERROR: Could not build wheels for box2d-py on windows install.

BlockchainPunks avatar Jan 11 '24 05:01 BlockchainPunks

You can install windows SDK. it can resolve your issue

krishdotn1 avatar Jan 15 '24 10:01 krishdotn1