Path error
Chenhao-Huang opened this issue · 15 comments
Hi there,
When I try to run python run.py
, I encountered the error /scripts/annotate_binder_program.py
.
After I change the third line of run.py
to ROOT_DIR = './'
, the error message becomes:
File ".//scripts/annotate_binder_program.py", line 15, in
from generation.generator import Generator
ModuleNotFoundError: No module named 'generation'
Would you please take a look for me? Thanks.
My OS in macOS. Are u using an Ubuntu?
Hi,
Thanks for asking, we also used the macOS so it shouldn't be due to the system. Could you try to add the binder
into the sources root?
Thanks!
I feel the problem is related to os.path.dirname
(ROOT_DIR is empty). I wrote is simple demo code. Is the following outputs meet your expectation?
(binder) [Binder]:[main]=>§ cat demo.py
import os
print(__file__)
ROOT_DIR=os.path.join(os.path.dirname(__file__))
print(ROOT_DIR)
((binder) [Binder]:[main]=>$ python3 demo.py
demo.py
I just checked,
mine is
/Users/xietianbao/Desktop/Binder/dd.py
/Users/xietianbao/Desktop/Binder
But will it be the fact that results in "ModuleNotFoundError: No module named 'generation'"?
Thanks a lot for checking that for me. I will try to fix things on my side.
Well. At a high level, this issue first causes some errors. After I fix those, "ModuleNotFoundError: No module named 'generation'" pops out.
Ok. I have found something interesting. When I execute the following python program in the conda environment Binder, it have the following output. However, if I execute in my base conda env, or other conda env, it works fine.
(binder) [Binder]:[main]=>§ cat demo.py
import os
print(__file__)
ROOT_DIR=os.path.join(os.path.dirname(__file__))
print(ROOT_DIR)
((binder) [Binder]:[main]=>$ python3 demo.py
demo.py
I find it is very likely related to python version. Python 3.7 seems to leads to the error I have, while python 3.9 is OK.
In the following code, the demo
conda env is initialised with
conda create -n flash python=3.9
(demo) [demo]: => $ cat demo.py
import os
print(__file__)
ROOT_DIR=os.path.join(os.path.dirname(__file__))
print(ROOT_DIR)
(demo) [demo]: => $ python --version
Python 3.7.16
(demo) [demo]: => $ python demo.py
demo.py
(demo) [demo]: => $ conda activate base
(base) [demo]: => $ python --version
Python 3.9.13
(base) [demo]: => $ python demo.py
/Users/chenhaohuang/Documents/GitHub/demo/demo.py
/Users/chenhaohuang/Documents/GitHub/demo
(base) [demo]: => $
Would you please take a look for me? Thanks in advance!
Hi, sorry for the delay, I was busy in town the day for the spring festival.
For your question, as you can see in environment config file, we used python==3.7.11 in anaconda, everything works fine.
Re-open this issue if you have further questions. Thanks for asking again!
One more comment.
python==3.7.11 actually receives the same error. I have another two experienced research also tried this, but failed. We are currently using Colab to management this environment.
hmmm... sorry but have you ever try using the command we provided to initial ize the env?
https://github.com/HKUNLP/Binder#dependencies
You mean the following commands? Yes. We all have initialised the env. We use conda to manage env in daily work.
========
conda env create -f py3.7binder.yaml
pip install records==0.5.3
conda activate binder
okkk. then that's really weird😂
yeah. We have tried both ubuntu and MacOS.
I met the same problem,but I have solved this problem.
You should create a path in you site-packages in the python path.
As for me, it is /home/g/anaconda3/envs/binder/lib/python3.7/site-packages. Then I create a file named pycharm.pth in this folder, and paste my project root path in it.
As for me, it is /home/g/Binder-main, and then, the project runs successfully.
I hope this helps you.