从不同的git repo-Python导入文件
在我的根主目录上,我有以下git存储库:从不同的git repo-Python导入文件,python,git,Python,Git,在我的根主目录上,我有以下git存储库: /root/foo /root/foo-lib /root/foo/scale/hello.py中的一个python文件,比如说hello.py,需要一个来自/root/foo lib的文件,名为bar.py(/root/foo lib/lib/bar.py) 在hello.py内,我可能有: import scale.test as test ... 还有很多其他的。但是,我需要将bar.py库导入该文件,该文件位于单独的存储库中。我怎样才能做到
/root/foo
/root/foo-lib
/root/foo/scale/hello.py
中的一个python文件,比如说hello.py
,需要一个来自/root/foo lib
的文件,名为bar.py
(/root/foo lib/lib/bar.py
)
在hello.py
内,我可能有:
import scale.test as test
...
还有很多其他的。但是,我需要将bar.py
库导入该文件,该文件位于单独的存储库中。我怎样才能做到这一点?我需要像这样的东西
import foo-lib.lib.bar as bar
在我的
hello.py
文件中。我不知道怎样才能做到这一点。有人能给我一个线索吗?你可以创建一个文件/root/\uuuu init\uuuuu.py
,在/root/foo/scale/hello.py
中,你可以使用这个语句
import ...foo-lib.lib.bar as bar
另一种选择是在
/root/foo/scale/
目录中创建一个符号链接,指向/root/foo lib
嗨,你能解决这个问题吗?