EvolutionGym / evogym

A large-scale benchmark for co-optimizing the design and control of soft robots, as seen in NeurIPS 2021.
https://evolutiongym.github.io/
MIT License
195 stars 33 forks source link

ModuleNotFoundError: No module named 'evogym.simulator_cpp'` #13

Closed ndr09 closed 3 months ago

ndr09 commented 2 years ago

I followed the instructions and installed Evogym on my pc (win 11). However, I have the following two problems and for both I will use the _evogym/tutorials/basicapi.py file as reference: 1) from pycharm it give the following error, while from the terminal it executes correctly Traceback (most recent call last): File "C:/Users/opuse/Desktop/evogym/tutorials/basic_api.py", line 1, in <module> from evogym.envs import * File "C:\Users\opuse\Desktop\evogym\evogym\__init__.py", line 2, in <module> from evogym.sim import EvoSim File "C:\Users\opuse\Desktop\evogym\evogym\sim.py", line 9, in <module> import evogym.simulator_cpp ModuleNotFoundError: No module named 'evogym.simulator_cpp' 2) If I move the basic_api.py out from the tutorials folder, hence in _evogym/basicapy.py, it will not execute returning the same error from 1

Thanks, Andrea

Titanium2099 commented 2 years ago

Same as #5 , everyone with windows hits this error

Yuxing-Wang-THU commented 2 years ago

Same as #5 , everyone with windows hits this error

I have successfully installed Evogym on Ubuntu and Centos, but I don't know how to fix this issuse on Windows.

ndr09 commented 2 years ago

so, ideally, if I use the HPC of my university which is linux based, I should not have problem calling from an outside folder? Or it depends also on the distro?

Edit: for both the problems adding the following code before importing the evogym makes the code run. Where folder is the position on the disk where you cloned the repo. in particular part 0 makes Pycharm able to run the code, while adding part 1 makes the code also running from a diverse folder. Note I am not sure of why this happens and I find the solution trying printing sys.path and looking for the differences

#### part 0
for i in range(len(sys.path)):
    if sys.path[i] == _folder_:
        pos.append(i)

if len(pos) > 0:
    for i in sorted(pos, reverse=True):
        sys.path.pop(i)
##### part 1
curr_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.join(curr_dir, 'evogym')
sys.path.insert(0, root_dir)

Thanks

d9w commented 1 year ago

This can happen if python looks for evogym in the current directory (for example, the source code), and not in its installed location in dist-packages. Notably, this will happen when using python setup.py install instead of pip install .. The compiled file simulator_cpp.py is only made in the dist-packages version

You can copy the generated simulator_cpp.py from the dist-packages installed version into your local directory or copy the full version locally if you used python setup.py install. However, using pip is probably safer and is possible with the modifications proposed in #27.

jagdeepsb commented 3 months ago

I've recently updated, simplified, and modernized EvoGym's build, which should fix this problem. Feel free to reopen this issue if the problem persists!