简体   繁体   English

在 Conda 虚拟环境中使用 Github 中的包

[英]Use package from Github in Conda Virtual Environment

Setup设置

  • Conda virtual environment Conda 虚拟环境
  • Coding in a Jupyter notebook在 Jupyter 笔记本中编码
  • Python version 3.6 Python 3.6 版

I have Googled, searched through the Conda help, github help on this site as wel as found closely relevant questions, that just don't answer mine:我已经谷歌搜索,通过 Conda 帮助搜索,本网站上的 github 帮助以及发现密切相关的问题,只是不回答我的:

That first one comes close though.不过,第一个接近。

Basically my question comes down to:基本上我的问题归结为:

For my code to work i need to import this repo: https://github.com/nicocanali/airtable-python为了让我的代码工作,我需要导入这个 repo: https : //github.com/nicocanali/airtable-python

How can I get this to be used in my Jupyter Notebook?我怎样才能在我的 Jupyter Notebook 中使用它?

I'll need to add it to my virtual environment.我需要将它添加到我的虚拟环境中。 But how?但是如何?

I ended up doing the following:我最终做了以下事情:

  1. Install git in the virtual environment: (conda install git)在虚拟环境中安装git:(conda install git)
  2. Clone the project.克隆项目。 (git clone [URL]) (git clone [URL])
  3. Install the package (cd to package directory that contains setup.py.安装包(cd 到包含 setup.py 的包目录。
  4. Then run "python setup.py install").然后运行“python setup.py install”)。

Found the answer in the first part in this video: How to Install Python Package from GitHub在本视频的第一部分找到答案:如何从 GitHub 安装 Python 包

Found a simple solution here:在这里找到了一个简单的解决方案:

https://medium.com/i-want-to-be-the-very-best/installing-packages-from-github-with-conda-commands-ebf10de396f4 https://medium.com/i-want-to-be-the-very-best/installing-packages-from-github-with-conda-commands-ebf10de396f4

For example, to install the package located at https://github.com/Netflix/metaflow , navigate to your desired environment in the Anaconda prompt, activate the environment, and then execute the following commands:例如,要安装位于https://github.com/Netflix/metaflow的软件包,在 Anaconda 提示符中导航到所需的环境,激活该环境,然后执行以下命令:

conda install git
conda install pip
pip install git+git://github.com/Netflix/metaflow.git

(Note that the git package is available in Anaconda Navigator, so can be installed from there instead of from the Anaconda prompt.) (注意 git 包在 Anaconda Navigator 中可用,因此可以从那里安装,而不是从 Anaconda 提示符安装。)

To install https://github.com/nicocanali/airtable-python to your jupyter.https://github.com/nicocanali/airtable-python安装到您的 jupyter。

Download the .zip of the repo from the github website.从 github 网站下载 repo 的 .zip。

To install it in jupyter enter the following command from the anaconda console.要在 jupyter 中安装它,请从 anaconda 控制台输入以下命令。

pip install [path_to_.zip_file_on_pc]

Works on any github file适用于任何 github 文件

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

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