创建用于安装API的setup.py

时间:2019-11-04 03:55:25

标签: python github pip

https://github.com/SocksPls/hltv-api.git,当我尝试安装时出现此错误

Collecting git+https://github.com/SocksPls/hltv-api.git
  Cloning https://github.com/SocksPls/hltv-api.git to c:\users\shait\appdata\local\temp\pip-req-build-h5h_opsb
  Running command git clone -q https://github.com/SocksPls/hltv-api.git 'C:\Users\shait\AppData\Local\Temp\pip-req-build-h5h_opsb'
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\shait\appdata\local\programs\python\python37-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\shait\\AppData\\Local\\Temp\\pip-req-build-h5h_opsb\\setup.py'"'"'; __file__='"'"'C:\\Users\\shait\\AppData\\Local\\Temp\\pip-req-build-h5h_opsb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\shait\AppData\Local\Temp\pip-req-build-h5h_opsb\pip-egg-info'
         cwd: C:\Users\shait\AppData\Local\Temp\pip-req-build-h5h_opsb\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\shait\appdata\local\programs\python\python37-32\lib\tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\shait\\AppData\\Local\\Temp\\pip-req-build-h5h_opsb\\setup.py'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

如果没有setup.py文件,Pip无法下载,我该如何创建它?

1 个答案:

答案 0 :(得分:2)

您链接的项目没有setup.py,因此pip无法实际安装。您正在寻找的最有可能做的事情:

git clone https://github.com/SocksPls/hltv-api

进入新的/hltv-api文件夹并执行以下操作:

pip install -r requirements.txt

从那里您将可以在项目中使用/修改/导入main.py。但是请注意,您将只能从同一目录中导入main.py文件。在同一目录中创建一个tool.py并使用以下模块:

import main as hltv
hltv.top5teams()