Python Pypi包安装可以在Linux上工作,但不能在Windows上工作 介绍
我正在创建一个包来解决路线问题。我在重数学部分使用Cython来提高速度 在LinuxSO(Ubuntu18.04)中,一切都很完美。但在Windows 10中,无法通过Python Pypi包安装可以在Linux上工作,但不能在Windows上工作 介绍,python,python-3.x,cython,setuptools,pypi,Python,Python 3.x,Cython,Setuptools,Pypi,我正在创建一个包来解决路线问题。我在重数学部分使用Cython来提高速度 在LinuxSO(Ubuntu18.04)中,一切都很完美。但在Windows 10中,无法通过pip install skroute 我正在使用Python 3.7 这是setup.py文件: import os from setuptools import setup, find_packages from setuptools.extension import Extension from Cython.Build
pip install skroute
我正在使用Python 3.7
这是setup.py
文件:
import os
from setuptools import setup, find_packages
from setuptools.extension import Extension
from Cython.Build import cythonize
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
extensions = cythonize([
Extension(
"skroute.heuristics.brute._base_brute_force._base_brute_force",
sources=["skroute/heuristics/brute/_base_brute_force/_base_brute_force.pyx"]),
Extension(
"skroute.metaheuristics.genetics._base_genetics._utils_genetic",
sources=["skroute/metaheuristics/genetics/_base_genetics/_utils_genetic.pyx"]),
Extension(
"skroute._utils._utils",
sources=["skroute/_utils/_utils.pyx"]),
Extension(
"skroute.metaheuristics.genetics._base_genetics._base_genetic",
sources=["skroute/metaheuristics/genetics/_base_genetics/_base_genetic.pyx"]),
Extension(
"skroute.metaheuristics.simulated_annealing._base_simulated_annealing._base_simulated_annealing",
sources=["skroute/metaheuristics/simulated_annealing/_base_simulated_annealing/_base_simulated_annealing.pyx"]),
Extension(
"skroute.metaheuristics.simulated_annealing._base_simulated_annealing._utils_sa",
sources=["skroute/metaheuristics/simulated_annealing/_base_simulated_annealing/_utils_sa.pyx"]),
])
HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, "README.md")) as fid:
README = fid.read()
with open(os.path.join(HERE, "requirements.txt")) as f:
REQUIREMENTS = f.read().splitlines()
setup(
name="scikit-route",
version="1.0.0a1 ",
description="Compute Routes easy and fast",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/arubiales/scikit-route",
author="Alberto Rubiales",
author_email="al.rubiales.b@gmail.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9"
],
packages=find_packages(),
setup_requires=[
'setuptools>=18.0',
"cython"
],
install_requires=REQUIREMENTS,
ext_modules = extensions,
include_package_data=True,
package_data={"": ["datasets/_data/_latitude_longitude/*.tsp", "datasets/*.txt", "datasets/_data/_money_cost/*.pkl"]},
)
问题
当我尝试从Pypi在Windows 10上安装该软件包时,出现以下错误:
ERROR: Command errored out with exit status 1:
command: 'C:\Users\whast\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\whast\\AppData\\Local\\Temp\\pip-install-dhvqmkkc\\scikit-route\\setup.py'"'"'; _file='"'"'C:\\Users\\whast\\AppData\\Local\\Temp\\pip-install-dhvqmkkc\\scikit-route\\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\whast\AppData\Local\Temp\pip-pip-egg-info-uqcw3lxf'
cwd: C:\Users\whast\AppData\Local\Temp\pip-install-dhvqmkkc\scikit-route\
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\whast\AppData\Local\Temp\pip-install-dhvqmkkc\scikit-route\setup.py", line 40, in <module>
extensions = cythonize([
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
module_list, module_metadata = create_extension_list(
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
raise ValueError(error_msg)
ValueError: 'skroute/heuristics/brute/_base_brute_force/_base_brute_force.pyx' doesn't match any files
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
错误:命令出错,退出状态为1:
命令:“C:\Users\whast\anaconda3\python.exe'-C”import sys,setuptools,tokenize;sys.argv[0]=“C:\\Users\\whast\\AppData\\Local\\Temp\\pip install dhvqmkc\\scikit route\\setup.py”“”_文件=“”“'C:\\Users\\whast\\AppData\\Local\\Temp\\pip install dhvqmkc\\scikit route\\setup.py”“”;f=getattr(标记化,“‘打开’”,打开)(文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,“'exec'”)“egg\u info--egg base”C:\Users\whast\AppData\Local\Temp\pip-pip-egg-info-uqcw3lxf”
cwd:C:\Users\whast\AppData\Local\Temp\pip安装dhvqmkkc\scikit路由\
完整输出(11行):
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Users\whast\AppData\Local\Temp\pip install dhvqmkc\scikit route\setup.py”,第40行,在
扩展=cythonize([
cythonize中的文件“C:\Users\whast\anaconda3\lib\site packages\Cython\Build\Dependencies.py”,第965行
模块列表,模块元数据=创建扩展列表(
文件“C:\Users\whast\anaconda3\lib\site packages\Cython\Build\Dependencies.py”,第815行,在创建扩展名列表中
对于非空(已排序的(扩展的_iglob(filepattern))文件,“'%s'与任何文件“%filepattern”都不匹配):
文件“C:\Users\whast\anaconda3\lib\site packages\Cython\Build\Dependencies.py”,第114行,非空
提升值错误(错误消息)
ValueError:“skroute/heuristics/brute/\u base\u brute\u force/\u base\u brute\u force.pyx”与任何文件都不匹配
----------------------------------------
错误:命令出错,退出状态为1:python setup.py egg_info检查日志以获得完整的命令输出。
此处,安装程序正在尝试对cythonize
a.pyx
文件进行加密,但未找到路径。
创建包的过程
我创建包所做的是:
python-m setup.py sdist bdist\u wheel
创建.whl
文件auditwheel
修复该文件,需要将带有Cython模块的包上载到Pypi,并使该包在所有linux发行版中都可用。我运行auditwheel修复区/scikit_路径…whl
setuptools
创建的.whl
替换为dist
文件夹中从auditwheel
重新安装的文件dist
文件夹上载到Pypi,因此我运行python-m twine upload dist/*
sys.path.Append(“/”).join(os.path.abspath(_文件_).split(“/”[:-1])安装,但未成功
Python setup.py sdist bdist_wheel
和pip install dist/*.whl
之后,我可以在Windows 10中安装该软件包,因此auditwheel
我怀疑问题是在我使用auditwheel
修复时出现的
正如我在“创建包的过程”第二点中所说:
使用auditwheel
修复文件,需要将带有Cython模块的包上载到Pypi。我运行auditwheel修复区/scikit_路径…whl
如果你知道如何使它工作,我将非常感谢你的帮助
可能的兴趣链接:
我猜您的上传过程有问题,因为PyPI中只有一个版本的skroute
,它是1.0.0a1。它没有Windows控制盘,所以它下载skroute-1.0.0a1.tar.gz
。或者您从PyPI中删除了Windows控制盘吗?在Linux上使用控制盘(至少如果您使用Python3.7进行测试)但在Windows上,它是从缺少pyx文件的源发行版构建的(我想您没有将其包含在包中)因此无法构建。是的,我没有.zip
文件,但这是问题所在吗?有必要吗?当我从github下载pip时,我使用.whl
和tar.gz
,一切都运行得很好。我试图创建zip
文件,但出现了相同的错误。我认为这是的问题e> auditwheel
和Windows。您可能希望在setup.py
旁边的文件中创建一个清单,内容为递归包含skroute*.pyx\n递归包含skroute*.pxd\n递归包含skroute*.pxi
以及生成扩展名所需的任何其他源文件。然后重新创建sdist。@cgohlke我变得疯狂了…我完全忘记了!谢谢你的帮助。如果你想创造和回答我,我会正确和赞成,你应得的。