在 conda 环境中安装自己的 python 包
Install own python package in conda environment
我开始编写自己的 python 包,并想将其安装在我的虚拟 conda 环境中。现在,我对这样做的可能性有点困惑。
一般来说,在我的搜索过程中,我发现了这两个命令来安装我的包:
pip install -e <my_package>
conda-develop .
如果已调用 conda list
,则使用第一种方法会得到预期的结果并列出我的包(尽管该包在 anaconda 导航器中仍然不可见,但无论如何)。
与此相反,第二种方法只返回 "completed operation for: " ,但没有在我的环境中安装包。
有谁知道这可能是什么或者我做错了什么?据我所知,也有可能直接在 conda 中创建包。如果它只是我的私人包裹,有什么好处吗?
提前致谢。
我认为是这样的。当您设置了 conda 环境时。 conda 中的包将被视为全局包。因此,如果您的 conda 环境中安装了一个包,并且您在 vent 环境中选择了 conda 解释器,则该包将可用。根据你的问题,你想要的是能够安装一个只在这个 vent 环境中可用的包。在这种情况下,您可以使用终端转到您的项目路径。然后使用正常的 pip install
,这样包将只在 vent 环境中。
Issues may arise when using pip and conda together. When combining
conda and pip, it is best to use an isolated conda environment. Only
after conda has been used to install as many packages as possible
should pip be used to install any remaining software. If modifications
are needed to the environment, it is best to create a new environment
rather than running conda after pip. When appropriate, conda and pip
requirements should be stored in text files.
Use pip only after conda Install as many requirements as possible with
conda then use pip.
Pip should be run with --upgrade-strategy only-if-needed (the
default).
Do not use pip with the --user argument, avoid all users installs.
而here是关于将conda与pip一起使用的官方行会。
我开始编写自己的 python 包,并想将其安装在我的虚拟 conda 环境中。现在,我对这样做的可能性有点困惑。 一般来说,在我的搜索过程中,我发现了这两个命令来安装我的包:
pip install -e <my_package>
conda-develop .
如果已调用 conda list
,则使用第一种方法会得到预期的结果并列出我的包(尽管该包在 anaconda 导航器中仍然不可见,但无论如何)。
与此相反,第二种方法只返回 "completed operation for:
有谁知道这可能是什么或者我做错了什么?据我所知,也有可能直接在 conda 中创建包。如果它只是我的私人包裹,有什么好处吗?
提前致谢。
我认为是这样的。当您设置了 conda 环境时。 conda 中的包将被视为全局包。因此,如果您的 conda 环境中安装了一个包,并且您在 vent 环境中选择了 conda 解释器,则该包将可用。根据你的问题,你想要的是能够安装一个只在这个 vent 环境中可用的包。在这种情况下,您可以使用终端转到您的项目路径。然后使用正常的 pip install
,这样包将只在 vent 环境中。
Issues may arise when using pip and conda together. When combining conda and pip, it is best to use an isolated conda environment. Only after conda has been used to install as many packages as possible should pip be used to install any remaining software. If modifications are needed to the environment, it is best to create a new environment rather than running conda after pip. When appropriate, conda and pip requirements should be stored in text files.
Use pip only after conda Install as many requirements as possible with conda then use pip.
Pip should be run with --upgrade-strategy only-if-needed (the default).
Do not use pip with the --user argument, avoid all users installs.
而here是关于将conda与pip一起使用的官方行会。