gpt4 book ai didi

python - pip 编辑模式 "Module not found"

转载 作者:行者123 更新时间:2023-12-01 09:25:08 24 4
gpt4 key购买 nike

我正在尝试在可编辑模式下使用使用 pip 的项目。我进行了广泛的搜索,发现有几个人遇到了这个问题(https://github.com/pypa/pip/issues/3),尽管提到的解决方案对我不起作用。

我在这里创建了一个示例项目:https://github.com/lfoppiano/testPip ,在几个依赖项中,问题在于 http://github.com/hirmeos/entity-fishing-client-python (参见分支 newVersion)。

我已经使用 python 3 配置了 virtualenv:

(venv3) Johan:hirmeos lfoppiano$ python --version
Python 3.6.5

如果我安装各种依赖项

(venv3) Johan:testPip lfoppiano$ pip install -r requirements.txt
Requirement already satisfied: requests==2.18.4 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from -r requirements.txt (line 1)) (2.18.4)
Requirement already satisfied: zenlog==1.1 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from -r requirements.txt (line 2)) (1.1)
Requirement already satisfied: bottle in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from -r requirements.txt (line 3)) (0.12.13)
Requirement already satisfied: networkx in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from -r requirements.txt (line 4)) (2.1)
Requirement already satisfied: beautifulsoup4 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from -r requirements.txt (line 5)) (4.6.0)
Collecting entity-fishing-client>=0.3.0 (from -r requirements.txt (line 6))
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests==2.18.4->-r requirements.txt (line 1)) (1.22)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests==2.18.4->-r requirements.txt (line 1)) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests==2.18.4->-r requirements.txt (line 1)) (2.6)
Requirement already satisfied: certifi>=2017.4.17 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests==2.18.4->-r requirements.txt (line 1)) (2018.1.18)
Requirement already satisfied: colorlog in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from zenlog==1.1->-r requirements.txt (line 2)) (2.10.0)
Requirement already satisfied: decorator>=4.1.0 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from networkx->-r requirements.txt (line 4)) (4.2.1)
Installing collected packages: entity-fishing-client
Successfully installed entity-fishing-client-0.4.0
(venv3) Johan:testPip lfoppiano$

一切正常:

(venv3) Johan:testPip lfoppiano$ python RootPage.py 8080
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.

但是,如果我安装依赖项entity-fishing-client,newVersion分支:https://github.com/hirmeos/entity-fishing-client-python/tree/newVersion在可编辑模式下通过 pip:

(venv3) Johan:hirmeos lfoppiano$ git clone git@github.com:hirmeos/entity-fishing-client-python.git testDependency
Cloning into 'testDependency'...
remote: Counting objects: 182, done.
remote: Total 182 (delta 0), reused 0 (delta 0), pack-reused 182
Receiving objects: 100% (182/182), 31.71 KiB | 328.00 KiB/s, done.
Resolving deltas: 100% (83/83), done.
(venv3) Johan:hirmeos lfoppiano$ git checkout newVersion



(venv3) Johan:hirmeos lfoppiano$ cd testDependency/
(venv3) Johan:testDependency lfoppiano$ git checkout newVersion
Branch 'newVersion' set up to track remote branch 'newVersion' from 'origin'.
Switched to a new branch 'newVersion'

(venv3) Johan:testDependency lfoppiano$ cd ..
(venv3) Johan:hirmeos lfoppiano$ cd testPip/
(venv3) Johan:testPip lfoppiano$ pip install -e ../testDependency/
Obtaining file:///Users/lfoppiano/development/inria/projects/hirmeos/testDependency
Requirement already satisfied: requests in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from entity-fishing-client==0.4.0) (2.18.4)
Requirement already satisfied: zenlog in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from entity-fishing-client==0.4.0) (1.1)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests->entity-fishing-client==0.4.0) (1.22)
Requirement already satisfied: idna<2.7,>=2.5 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests->entity-fishing-client==0.4.0) (2.6)
Requirement already satisfied: certifi>=2017.4.17 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests->entity-fishing-client==0.4.0) (2018.1.18)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from requests->entity-fishing-client==0.4.0) (3.0.4)
Requirement already satisfied: colorlog in /Users/lfoppiano/.virtualenvs/venv3/lib/python3.6/site-packages (from zenlog->entity-fishing-client==0.4.0) (2.10.0)
Installing collected packages: entity-fishing-client
Running setup.py develop for entity-fishing-client
Successfully installed entity-fishing-client
(venv3) Johan:testPip lfoppiano$

当我运行它时,我收到错误:

(venv3) Johan:testPip lfoppiano$ python RootPage.py 
Traceback (most recent call last):
File "RootPage.py", line 9, in <module>
from nerd.nerd import NerdClient
ModuleNotFoundError: No module named 'nerd'

提前谢谢

最佳答案

您将无法在开发模式下安装和使用 entity-fishing-client,因为 setuptools 无法处理与 package_dir< 的包名称映射 处于开发模式; this is an old issue 。要么不要使用开发模式,并在每次需要应用更改时手动重新安装:pip uninstall -yentity-fishing-client && pip install testDependency/ 或将包根目录重命名为 > Nerd 并调整设置脚本:

$ pip uninstall -y entity-fishing-client
$ rm -rf testDependency/entity_fishing_client.egg_info
$ mv testDependency/entity-fishing_client testDependency/nerd
$ sed -i '/package_dir=/d' testDependency/setup.py
$ pip install --editable testDependency/
$ python -c "from nerd.nerd import NerdClient; print('ok')"
ok

关于python - pip 编辑模式 "Module not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50487626/

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