Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从不同的git repo-Python导入文件_Python_Git - Fatal编程技术网

从不同的git repo-Python导入文件

从不同的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库导入该文件,该文件位于单独的存储库中。我怎样才能做到

在我的根主目录上,我有以下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
库导入该文件,该文件位于单独的存储库中。我怎样才能做到这一点?我需要像这样的东西

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

嗨,你能解决这个问题吗?