Pip安装由于包要求依赖关系而失败

2024-04-28 08:07:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我发布了一个python3package到PyPI(使用this优秀的cookiecutter模板),它依赖于用Cython编写的^{cd1>}扩展、使用Numba的JIT编译和其他依赖于Numpy的包等等。在

当我没有在requirements.txt和\或install_requires中的setupy.py中指定任何要求时,包将成功安装,这表明cookiecutter模板正确地完成了它的工作。此外,像AppVeyorTravis这样的CI工具可以成功地构建我的包并对其进行测试。在

但是,当我输入需求列表时,无论顺序如何,pip install命令都会失败(在一个简单的虚拟环境中),并且CI工具也无法构建它(错误日志在上面的链接中可见)。如果我在那个虚拟环境中预先安装Numba,然后尝试pip install一切正常。这在Windows(10)和CentOS上都得到了复制。在

我怀疑当这个问题得到解决时,CI工具也能成功地构建我的包。在

Windows日志:

C:\Users\Hagai\Documents\GitHub\python-pysight>activate py36

(py36) C:\Users\Hagai\Documents\GitHub\python-pysight>pip install pysight
Collecting pysight
  Downloading pysight-0.1.6-cp36-cp36m-win_amd64.whl (113kB)
    100% |████████████████████████████████| 122kB 460kB/s
Collecting attrs>=1.6 (from pysight)
  Using cached attrs-16.3.0-py2.py3-none-any.whl
Collecting tables (from pysight)
  Using cached tables-3.3.0-cp36-cp36m-win_amd64.whl
Collecting pandas (from pysight)
  Using cached pandas-0.19.2-cp36-cp36m-win_amd64.whl
Collecting numba (from pysight)
  Using cached numba-0.31.0.tar.gz
Collecting matplotlib (from pysight)
  Using cached matplotlib-2.0.0-cp36-cp36m-win_amd64.whl
Collecting tifffile (from pysight)
Collecting cython (from pysight)
Collecting numpy>=1.8.0 (from tables->pysight)
  Using cached numpy-1.12.0-cp36-none-win_amd64.whl
Collecting numexpr>=2.5.2 (from tables->pysight)
  Using cached numexpr-2.6.2-cp36-none-win_amd64.whl
Collecting six (from tables->pysight)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pytz>=2011k (from pandas->pysight)
  Using cached pytz-2016.10-py2.py3-none-any.whl
Collecting python-dateutil>=2 (from pandas->pysight)
  Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Collecting llvmlite (from numba->pysight)
  Using cached llvmlite-0.16.0.tar.gz
Collecting cycler>=0.10 (from matplotlib->pysight)
  Using cached cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib->pysight)
  Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Building wheels for collected packages: numba, llvmlite
  Running setup.py bdist_wheel for numba ... error
  Complete output from command C:\Users\Hagai\Anaconda3\envs\py36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hagai\\AppData\\Local\\Temp\\pip-build-ry0rxpw8\\numba\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Hagai\AppData\Local\Temp\tmpd75ai9dzpip-wheel- --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\numba\setup.py", line 250, in <module>
      metadata['ext_modules'] = get_ext_modules()
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\numba\setup.py", line 82, in get_ext_modules
      import numpy.distutils.misc_util as np_misc
  ModuleNotFoundError: No module named 'numpy'

  ----------------------------------------
  Failed building wheel for numba
  Running setup.py clean for numba
  Complete output from command C:\Users\Hagai\Anaconda3\envs\py36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hagai\\AppData\\Local\\Temp\\pip-build-ry0rxpw8\\numba\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\numba\setup.py", line 250, in <module>
      metadata['ext_modules'] = get_ext_modules()
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\numba\setup.py", line 82, in get_ext_modules
      import numpy.distutils.misc_util as np_misc
  ModuleNotFoundError: No module named 'numpy'

  ----------------------------------------
  Failed cleaning build dir for numba
  Running setup.py bdist_wheel for llvmlite ... error
  Complete output from command C:\Users\Hagai\Anaconda3\envs\py36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hagai\\AppData\\Local\\Temp\\pip-build-ry0rxpw8\\llvmlite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Hagai\AppData\Local\Temp\tmpcioz28cjpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  got version from file C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\llvmlite/_version.py {'version': '0.16.0', 'full': '964cf1d6d725b000c769379a5efe11932fcfc551'}
  running build_ext
  C:\Users\Hagai\Anaconda3\envs\py36\python.exe C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py
  Trying generator 'Visual Studio 12 2013 Win64'
  Traceback (most recent call last):
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 152, in <module>
      main()
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 140, in main
      main_win32()
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 74, in main_win32
      generator = find_win32_generator()
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 62, in find_win32_generator
      try_cmake(cmake_dir, build_dir, generator)
    File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 27, in try_cmake
      subprocess.check_call(['cmake', '-G', generator, cmake_dir])
    File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 286, in check_call
      retcode = call(*popenargs, **kwargs)
    File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 267, in call
      with Popen(*popenargs, **kwargs) as p:
    File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 707, in __init__
      restore_signals, start_new_session)
    File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 990, in _execute_child
      startupinfo)
  FileNotFoundError: [WinError 2] The system cannot find the file specified
  error: command 'C:\\Users\\Hagai\\Anaconda3\\envs\\py36\\python.exe' failed with exit status 1

  ----------------------------------------
  Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Failed to build numba llvmlite
Installing collected packages: attrs, numpy, numexpr, six, tables, pytz, python-dateutil, pandas, llvmlite, numba, cycler, pyparsing, matplotlib, tifffile, cython, pysight
  Running setup.py install for llvmlite ... error
    Complete output from command C:\Users\Hagai\Anaconda3\envs\py36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hagai\\AppData\\Local\\Temp\\pip-build-ry0rxpw8\\llvmlite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Hagai\AppData\Local\Temp\pip-9a1uhuys-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    got version from file C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\llvmlite/_version.py {'version': '0.16.0', 'full': '964cf1d6d725b000c769379a5efe11932fcfc551'}
    running build_ext
    C:\Users\Hagai\Anaconda3\envs\py36\python.exe C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py
    Trying generator 'Visual Studio 12 2013 Win64'
    Traceback (most recent call last):
      File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 152, in <module>
        main()
      File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 140, in main
        main_win32()
      File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 74, in main_win32
        generator = find_win32_generator()
      File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 62, in find_win32_generator
        try_cmake(cmake_dir, build_dir, generator)
      File "C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\ffi\build.py", line 27, in try_cmake
        subprocess.check_call(['cmake', '-G', generator, cmake_dir])
      File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 286, in check_call
        retcode = call(*popenargs, **kwargs)
      File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 267, in call
        with Popen(*popenargs, **kwargs) as p:
      File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 707, in __init__
        restore_signals, start_new_session)
      File "C:\Users\Hagai\Anaconda3\envs\py36\lib\subprocess.py", line 990, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified
    error: command 'C:\\Users\\Hagai\\Anaconda3\\envs\\py36\\python.exe' failed with exit status 1

    ----------------------------------------
Command "C:\Users\Hagai\Anaconda3\envs\py36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hagai\\AppData\\Local\\Temp\\pip-build-ry0rxpw8\\llvmlite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Hagai\AppData\Local\Temp\pip-9a1uhuys-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Hagai\AppData\Local\Temp\pip-build-ry0rxpw8\llvmlite\

CentOS日志:

^{pr2}$

Tags: pipinfrompybuildlocallineusers