自定义Python包安装失败求助:pip install -e执行报错
自定义Python模块可编辑安装报错问题
需求
实现Jupyter Notebook能导入自定义Python模块,目标是通过from projectmnemonic import test完成导入,采用可编辑模式(-e参数)安装本地包。
项目目录结构
my-datascience-project/ ... notebooks/ ... projectmnemonic/ projectmnemonic/ __init__.py test.py setup.py ...
setup.py代码
from setuptools import setup setup( name="projectmnemonic", version="0.1", )
报错的安装操作
在激活的Anaconda环境中执行以下命令:
pip install -e path/to/my-datascience-project/projectmnemonic
报错信息
Defaulting to user installation because normal site-packages is not writeable Looking in indexes: <redacted> Obtaining <path to my-datascience-project/projectmnemonic> Preparing metadata (setup.py) ... done Installing collected packages: <projectmnemonic> Running setup.py develop for <projectmnemonic> error: subprocess-exited-with-error × python setup.py develop did not run successfully. │ exit code: 1 ╰─> [6 lines of output] running develop C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools. warnings.warn( C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( error: --egg-path must be a relative path from the install directory to <projectmnemonic>. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × python setup.py develop did not run successfully. │ exit code: 1 ╰─> [6 lines of output] running develop C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools. warnings.warn( C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( error: --egg-path must be a relative path from the install directory to <projectmnemonic>. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip.
成功的安装操作
将projectmnemonic目录移至桌面后,执行相同的安装命令,安装过程无报错:
Defaulting to user installation because normal site-packages is not writeable Looking in indexes: <redacted> Obtaining <path to my-datascience-project/projectmnemonic> Preparing metadata (setup.py) ... done Installing collected packages: <projectmnemonic> Running setup.py develop for <projectmnemonic> Successfully installed <projectmnemonic>-0.1
环境版本信息
- Python 3.9.12
- setuptools 67.6.1
- pip 21.2.4
内容的提问来源于stack exchange,提问作者Jhonny
相关产品推荐
相关产品推荐

