Python 从Github运行安装和导入时出错
我正在使用python;科拉布。 我尝试从“github.com/jleinonen/kerasfid”安装程序包以导入Python 从Github运行安装和导入时出错,python,github,package,google-colaboratory,Python,Github,Package,Google Colaboratory,我正在使用python;科拉布。 我尝试从“github.com/jleinonen/kerasfid”安装程序包以导入fid。我第一次使用: !pip install git+git://github.com/jleinonen/keras-fid.git 但是我犯了错误 Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. 所以我
fid
。我第一次使用:
!pip install git+git://github.com/jleinonen/keras-fid.git
但是我犯了错误
Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
所以我用了:!git克隆
我通过使用从Github安装包
!git clone https://github.com/jleinonen/keras-fid.git
然后尝试导入模块
然而,我不确定,但我认为因为包名包含“-”,所以我得到了
如何从该软件包导入模块该
-
是个麻烦事。问题是Github repo不能pip安装
ed,因为它不包含setup.py
当您git clone
d代码时,只需将其复制到您的环境中即可。它仍然不是很容易安装的。。。尽管您现在可以做的是将克隆目录添加到PYTHONPATH
,或者将文件fid.py
从其内部复制到PYTHONPATH
上的某个位置
快速演示:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
bash$ git clone https://github.com/jleinonen/keras-fid.git
Cloning into 'keras-fid'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.
我不知道代码应该做什么,我对Keras或Google Colab一无所知;但将其更改为image\u range,
在逗号前不带等号至少可以让我绕过这个错误
似乎有一些关于如何在Google Colab中执行类似操作的提示。SyntaxerError似乎与前面的问题无关。您得到语法错误的原因是什么?仅仅克隆一个包还不能安装该包,因此您可以导入它。最好的解决方法可能是找出第一个
pip
失败的原因;它告诉您要查看哪些日志?这是收集git的完整日志+git://github.com/jleinonen/keras-fid.git克隆git://github.com/jleinonen/keras-fid.git 到/tmp/pip-req-build-g8o2sz7u
运行命令git clone-qgit://github.com/jleinonen/keras-fid.git /tmp/pip-req-build-g8o2sz7u
错误:命令出错,退出状态为1:python setup.py egg\u info检查日志以获取完整的命令输出。
您需要找到这些日志;可能查看/tmp/pip-req-build-g8o2sz7u
提交的错误报告:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
bash$ git clone https://github.com/jleinonen/keras-fid.git
Cloning into 'keras-fid'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
bash$ PYTHONPATH=${PYTHONPATH+$PYTHONPATH:}`pwd`/keras-fid python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/keras-fid/fid.py", line 134
def __init__(self, generator, image_range=,
^