简体   繁体   English

从 Github 导入模块以在 Python 中使用

[英]Importing module from Github to use in Python

I'm a beginner in Python and I have no experience with GitHub at all.我是 Python 的初学者,我完全没有 GitHub 的经验。 I want to import the module semsimlib from the following URL: https://github.com/timvdc/semsimlib我想从以下 URL 导入模块semsimlibhttps://github.com/timvdc/semsimlib

I have looked on the internet for help on how to do this but most of it is very unclear and doesn't seem to work for me.我已经在互联网上寻求有关如何执行此操作的帮助,但其中大部分都非常不清楚,似乎对我不起作用。 Can anyone provide a detailed explanation on how to do this in a easy way?谁能以简单的方式提供有关如何执行此操作的详细说明?

It looks the repo does not provide appropriate scripts to simply install the package.看起来 repo 没有提供适当的脚本来简单地安装 package。 There is no setup.py file and there is no distribution on pypi.没有setup.py文件,也没有在 pypi 上分发。

What you can do is go to site-packages folder inside your python installation or inside your virtual environment.您可以做的是 go 到您的 python 安装或虚拟环境中的site-packages文件夹。 Then run git clone https://github.com/timvdc/semsimlib .然后运行git clone https://github.com/timvdc/semsimlib You should now be able to import semsimlib .您现在应该可以导入semsimlib Keep in mind that you will also have to install all the other dependencies your self one by one since there is also no requirements file.请记住,您还必须自己安装所有其他依赖项,因为也没有requirements文件。

You can also clone the repo into any folder on your computer and at the top of your script put:您还可以将 repo 克隆到计算机上的任何文件夹中,并在脚本顶部放置:

import sys
sys.path.append("path/to/semsimlib/folder")

semsimlib will now be importable. semsimlib现在可以导入了。 However, I would try to get it to work with the first method.但是,我会尝试让它与第一种方法一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM