gpt4 book ai didi

Python包似乎忽略了我的要求

转载 作者:行者123 更新时间:2023-12-01 05:43:11 25 4
gpt4 key购买 nike

我创建了我的第一个包。当我尝试在新创建的 virtualenv 中使用 pip 安装它时,出现错误,指示无法导入库,但它们已添加到 setup.py 中的 install_requires 字段中。如果我在 vierualenv 之外执行此操作,则一切正常。我的 setup.py 在这里:https://github.com/tdi/pyPEPA/blob/dev/setup.py

重现错误:

mkvirtualenv something -p /usr/bin/python3
workon something
pip install pypepa

.

Downloading/unpacking pypepa
Running setup.py egg_info for package pypepa
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/tdi/.virtualenvs/koza/build/pypepa/setup.py", line 3, in <module>
import pypepa
File "./pypepa/__init__.py", line 6, in <module>
from pypepa.pepa_model import PEPAModel
File "./pypepa/pepa_model.py", line 6, in <module>
from pypepa.parsing.parser import PEPAParser
File "./pypepa/parsing/parser.py", line 5, in <module>
from pyparsing import Word, Literal, alphas, alphanums, nums, Combine, Optional, ZeroOrMore, Forward, restOfLine
ImportError: No module named 'pyparsing'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/tdi/.virtualenvs/koza/build/pypepa/setup.py", line 3, in <module>
import pypepa
File "./pypepa/__init__.py", line 6, in <module>
from pypepa.pepa_model import PEPAModel
File "./pypepa/pepa_model.py", line 6, in <module>
from pypepa.parsing.parser import PEPAParser
File "./pypepa/parsing/parser.py", line 5, in <module>
from pyparsing import Word, Literal, alphas, alphanums, nums, Combine, Optional, ZeroOrMore, Forward, restOfLine
ImportError: No module named 'pyparsing'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/tdi/.virtualenvs/koza/build/pypepa
Storing complete log in /home/tdi/.pip/pip.log

最佳答案

您的安装脚本导入了 pypepa,后者导入了 pypepa.pepa_model,后者导入了 pyparsing,但 pyparsing 尚未安装(我们甚至还没有完成运行安装脚本以了解依赖项是什么)。解决方案是在 pypepa 和 setup.py 中重复版本号(这样就可以删除导入),或者不在 __init__.py 中导入 PEPAModel。

关于Python包似乎忽略了我的要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16938890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com