我正在使用Pipenv创建一个Python项目,并且具有以下Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
black = "==19.10b0"
pylint = "==2.4.4"
pytest = "==5.3.1"
pytest-mock = "==1.13.0"
pytest-flask = "==0.15.0"
[packages]
python-decouple = "==3.3"
pytz = "*"
Flask = "==1.1.1"
Flask-RESTful = "==0.3.7"
uWSGI = "==2.0.18"
[requires]
python_version = "3.8"
我的问题是uWSGI
软件包仅适用于Linux,而我正在使用Windows。因此,每当我运行pipenv install
时,它都会因此失败。有没有办法告诉Pipenv仅在Windows环境中忽略此软件包的安装?
更新
这是命令的结果:pipenv lock -r
Pipfile.lock (e1b4e4) out of date, updating to (5696f6)…
Locking [dev-packages] dependencies…
Success!
Locking [packages] dependencies…
Locking Failed!
Traceback (most recent call last):
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 126, in <module>
main()
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 118, in main
_main(parsed.pre, parsed.clear, parsed.verbose, parsed.system,
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 78, in _main
results = resolve(
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 61, in resolve
return resolve_deps(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 718, in resolve_deps
resolved_tree, hashes, markers_lookup, resolver = actually_resolve_deps(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 480, in actually_resolve_deps
resolved_tree = resolver.resolve()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 385, in resolve
results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 206, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 301, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 234, in get_dependencies
legacy_results = self.get_legacy_dependencies(ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 426, in get_legacy_dependencies
results, ireq = self.resolve_reqs(download_dir, ireq, wheel_cache)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 297, in resolve_reqs
results = resolver._resolve_one(reqset, ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\resolve.py", line 260, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\resolve.py", line 211, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 294, in prepare_linked_requirement
abstract_dist.prep_for_dist(finder, self.build_isolation)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 127, in prep_for_dist
self.req.run_egg_info()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 470, in run_egg_info
call_subprocess(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\utils\misc.py", line 703, in call_subprocess
raise InstallationError(
pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in C:\Users\FELIPE~1\AppData\Local\Temp\tmpuyfdyzgwbuild\uwsgi\
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 126, in <module>
main()
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 118, in main
_main(parsed.pre, parsed.clear, parsed.verbose, parsed.system,
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 78, in _main
results = resolve(
File "c:/users/felipe a/appdata/local/programs/python/python38-32/lib/site-packages/pipenv/resolver.py", line 61, in resolve
return resolve_deps(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 718, in resolve_deps
resolved_tree, hashes, markers_lookup, resolver = actually_resolve_deps(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 480, in actually_resolve_deps
resolved_tree = resolver.resolve()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\utils.py", line 385, in resolve
results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 206, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\resolver.py", line 301, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 234, in get_dependencies
legacy_results = self.get_legacy_dependencies(ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 426, in get_legacy_dependencies
results, ireq = self.resolve_reqs(download_dir, ireq, wheel_cache)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\piptools\repositories\pypi.py", line 297, in resolve_reqs
results = resolver._resolve_one(reqset, ireq)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\resolve.py", line 260, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\resolve.py", line 211, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 294, in prepare_linked_requirement
abstract_dist.prep_for_dist(finder, self.build_isolation)
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\operations\prepare.py", line 127, in prep_for_dist
self.req.run_egg_info()
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\req\req_install.py", line 470, in run_egg_info
call_subprocess(
File "c:\users\felipe a\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\patched\notpip\_internal\utils\misc.py", line 703, in call_subprocess
raise InstallationError(
pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in C:\Users\FELIPE~1\AppData\Local\Temp\tmpuyfdyzgwbuild\uwsgi\
答案 0 :(得分:3)
除了版本,您可以在Pipenv文件中传递环境/操作系统。
对于您的示例(仅在Linux上具有uWSGI):
uWSGI = {version = "*", sys_platform = "== 'linux'"}
您可以使用以下方法检查sys_platform
:
import sys
print(sys.platform) #python3
如果您使用的是sys平台(例如win32
或linux
),则可以如上所述将sys_platform
添加到Pipenv文件中
这应该可以解决您的问题
编辑:
uWSGI当前与Windows集成有关:
Pipenv需要运行setup.py来检查源代码中的依赖项 分配。您将需要让uWSGI释放轮子,或者在 至少使setup.py egg_info在Windows上工作(库本身 不需要工作,只需setup.py)。 来自github.com/pypa/pipenv/issues/3084
使用此代码,您可以解决我尝试过的问题,并且可以正常工作:
# make pipenv lock uwsgi works under windows
# add func to os.py in virtualenv
def uname():
import inspect
caller = inspect.getmodule(inspect.stack()[1][0]).__name__
if caller == 'uwsgiconfig':
return ("", "", "", "", "")
raise AttributeError()
*来自gist.github.com/hulucc/669b3f9cc379f017840285fb2bed3387的代码*
答案 1 :(得分:0)
我在使用 bjoern
时遇到了同样的问题,它不支持 Windows。
我的工作语法是:
bjoern = {version = "*", markers="sys_platform == 'linux'"}
它显示了一个警告。