首页 > 解决方案 > 如何在python中安装light包?

问题描述

当我使用命令在 python 3.6.5 中安装 light 包时

pip install light

我收到此错误:

Collecting light
  Using cached https://files.pythonhosted.org/packages/74/e5/78270f0aec7135793a85d4898b0075b741f7e2041011c24d8af76c9a3671/light-0.0.1.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Bhanu\AppData\Local\Temp\pip-install-p6x112xj\light\setup.py", line 43, in <module>
        with open(os.path.join(thisdir, "requirements.txt"), "r") as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Bhanu\\AppData\\Local\\Temp\\pip-install-p6x112xj\\light\\requirements.txt'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\Bhanu\AppData\Local\Temp\pip-install-p6x112xj\light\

标签: python-3.6

解决方案


看起来该项目不再维护。

如果您从 pypi ( light-0.0.1.tar.gz )下载整个源代码,将其解压到light-0.0.1目录,然后检查setup.py,则有一部分代码正在寻找requirements.txt文件:

 42 install_requires = []
 43 with open(os.path.join(thisdir, "requirements.txt"), "r") as f:
 44     install_requires.extend(line.strip() for line in f.readlines() if line.strip())
 45 

但很明显requirements.txt不存在:

|- light
|- light.egg-info
|- PKG-INFO
|- setup.cfg
|- setup.py

您可以尝试在同一目录中创建一个空白requirements.txt文件,或者从setup.py中注释掉那些正在寻找requirements.txt的行:

install_requires = []
#with open(os.path.join(thisdir, "requirements.txt"), "r") as f:
#    install_requires.extend(line.strip() for line in f.readlines() if line.strip())

然后手动安装包:

$ cd <path/to/light-0.0.1>
$ pip3 install .

它将成功安装。

不过,我建议远离这个包,因为它看起来不再维护或尚未准备好发布生产版本。


推荐阅读