简体   繁体   English

无法从github安装python库

[英]Unable to install python library from github

My OS is OSX 10.10.5 and I use Anaconda distribution for python. 我的操作系统是OSX 10.10.5,我将Anaconda发行版用于python。 I am trying to install the following library from github: https://github.com/gmum/pykernels 我正在尝试从github安装以下库: https : //github.com/gmum/pykernels

When I try to use pip install: 当我尝试使用pip安装时:

pip install git+https://github.com/gmum/pykernels.git

I get the following error: 我收到以下错误:

Collecting git+https://github.com/gmum/pykernels.git
  Cloning https://github.com/gmum/pykernels.git to /var/folders/dd/98c207155h57757dtxkyp44r0000gn/T/pip-x7zo1w22-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Conda3/anaconda/lib/python3.5/tokenize.py", line 454, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/dd/98c207155h57757dtxkyp44r0000gn/T/pip-x7zo1w22-build/setup.py'  

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /var/folders/dd/98c207155h57757dtxkyp44r0000gn/T/pip-x7zo1w22-build/

Pip install works well for other libraries and my setuptools is also up to date. Pip安装对于其他库非常有效,我的setuptools也处于最新状态。

The problem is, that library doesn't have a setup.py file. 问题是该库没有setup.py文件。 pip executes/follows this file. pip执行/关注此文件。 so that library cannot be installed using pip. 因此无法使用pip安装库。 You can, however, download and put that library (the pykernels folder inside the repo) in your current folder or add it's path to sys.path like this: 但是,您可以下载该库(存储库中的pykernels文件夹)并将其放在当前文件夹中,或者将其路径添加到sys.path如下所示:

import sys
sys.path.append("Path to pykernels repo") 

Be sure to install their dependencies using pip like this: 确保使用如下pip安装其依赖项:

pip install numpy scipy scikit-learn

Then you can just use import pykernels in your script. 然后,您可以在脚本中使用import pykernels

Edit : setup.py is now integrated to the repository and now you can just use pip : 编辑setup.py现在已集成到存储库中,现在您可以使用pip

pip install git+https://github.com/gmum/pykernels.git

Seems that https://github.com/gmum/pykernels.git does not contain valid installable python package. 似乎https://github.com/gmum/pykernels.git不包含有效的可安装python软件包。 There is no setup.py file in repo root directory but setup.py is required to installation. 回购根目录中没有setup.py文件,但安装需要setup.py

The repository is missing a setup.py file. 存储库缺少setup.py文件。 Without this pip does not know how to install the module/package. 没有此pip ,将不知道如何安装模块/软件包。

It looks like it's just a plain package without any setup scripts. 看起来这只是一个没有任何安装脚本的普通软件包。 You'll need to clone it and use it by copy/pasting it into your project or write your own setup.py file. 您需要克隆它并通过将其复制/粘贴到您的项目中或使用您自己的setup.py文件来使用它。

Here's the documentation . 这是文档 It's pretty straight forward. 非常简单。

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

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