Error on Ubuntu 20.04
LLLWQ opened this issue · 6 comments
I used Ubuntu 20.0 and Python 3.6 to run this project. I downloaded this repository and run these commands:
cd MAgent
sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev
bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH
When I used pycharm to mark the "Python" file in it as the Sources Root,and run the file "api_demo.py",it showed some error massages:
Traceback (most recent call last):
File "/home/lwq/PycharmProjects/MAgent/examples/api_demo.py", line 16, in
env.set_render_dir("build/render")
File "/home/lwq/PycharmProjects/MAgent/python/magent/gridworld.py", line 430, in set_render_dir
os.mkdir(name)
FileNotFoundError: [Errno 2] No such file or directory: 'build/render'
and when I run the file "train_battle.py", it showed:
Traceback (most recent call last):
File "examples/train_battle.py", line 12, in
import magent
ModuleNotFoundError: No module named 'magent'
Could you check the working directory when you run the api_demo.py
? By default, PyCharm will just set the working directory to be the folder of the script (in your case it's /home/lwq/PycharmProjects/MAgent/examples
). However, it's supposed to run all scripts in the root folder of MAgent, which could be fixed by setting the working directory manually to /home/lwq/PycharmProjects/MAgent
.
In the second case, could you also verify the PYTHONPATH
and the working directory are both set correctly?
Thank you very much for your reply. I reset the working directory, but the error still appeared:
(ITSC) lwq@lwq-Precision-7920-Tower:~/PycharmProjects/MAgent$ python examples/train_battle.py --train
Traceback (most recent call last):
File "examples/train_battle.py", line 14, in
import magent
ModuleNotFoundError: No module named 'magent'
I tried many ways, but failed to solve the problem. I sincerely hope you can reply.
The best way you can avoid running into issues is to run what's suggested in the terminal starting from scratch:
git clone https://github.com/geek-ai/MAgent
cd MAgent
sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev
bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH
python examples/train_battle.py --train
Please also attach the complete log of your console when your run these commands in order to understand your issues.
Once again, could you please make sure the PYTHONPATH
is set correctly in your case?
Thanks again for your reply. I tried your method. Instead of clone the project, I ran the command in the pycharm Terminal and was ready to run the program. Magic, I used to run these commands from anoconda terminal,I don't know what to say, It worked. Wishing you a happy day!