gpt4 book ai didi

python - 如何检查 conda develop 是否安装了我的项目/包?

转载 作者:行者123 更新时间:2023-12-03 22:00:20 26 4
gpt4 key购买 nike

如何查看我在开发模式下安装的软件包?
我试过 conda list但它没有显示任何熟悉的东西。

我跑了conda develop .它似乎安装了它:

(automl-meta-learning) brandomiranda~/automl-meta-learning/automl ❯ conda develop .
path exists, skipping /Users/brandomiranda/automl-meta-learning/automl
completed operation for: /Users/brandomiranda/automl-meta-learning/automl

但是,运行脚本时出现错误:
(automl-meta-learning) brandomiranda~/automl-meta-learning/automl/automl/meta_optimizers ❯ python differentiable_SGD.py
Traceback (most recent call last):
File "differentiable_SGD.py", line 8, in <module>
from automl.utils.torch_utils import helloworld
ModuleNotFoundError: No module named 'automl.utils'

但是当我做 conda list 时,我看不到任何我认识的东西:
(automl-meta-learning) brandomiranda~/automl-meta-learning/automl/automl/meta_optimizers ❯ conda list
# packages in environment at /Users/brandomiranda/miniconda3/envs/automl-meta-learning:
#
# Name Version Build Channel
appnope 0.1.0 py37_0
asn1crypto 1.3.0 py37_0
astroid 2.3.3 py37_0
attrs 19.3.0 py_0
backcall 0.1.0 py37_0
beautifulsoup4 4.8.2 py37_0
blas 1.0 mkl
bleach 3.1.0 py37_0
bzip2 1.0.8 h1de35cc_0
ca-certificates 2019.11.27 0
certifi 2019.11.28 py37_0
cffi 1.13.2 py37hb5b8e2f_0
chardet 3.0.4 py37_1003
conda 4.8.1 py37_0
conda-build 3.18.11 py37_0
conda-package-handling 1.6.0 py37h1de35cc_0
cryptography 2.8 py37ha12b0ac_0
cycler 0.10.0 py37_0
dbus 1.13.12 h90a0687_0
decorator 4.4.1 py_0
defusedxml 0.6.0 py_0
entrypoints 0.3 py37_0
expat 2.2.6 h0a44026_0
filelock 3.0.12 py_0
freetype 2.9.1 hb4e5f40_0
gettext 0.19.8.1 h15daf44_3
glib 2.63.1 hd977a24_0
glob2 0.7 py_0
icu 58.2 h4b95b61_1
idna 2.8 py37_0
importlib_metadata 1.3.0 py37_0
intel-openmp 2019.4 233
ipykernel 5.1.3 py37h39e3cac_1
ipython 7.11.1 py37h39e3cac_0
ipython_genutils 0.2.0 py37_0
ipywidgets 7.5.1 py_0
isort 4.3.21 py37_0
jedi 0.15.2 py37_0
jinja2 2.10.3 py_0
jpeg 9b he5867d9_2
jsonschema 3.2.0 py37_0
jupyter 1.0.0 py37_7
jupyter_client 5.3.4 py37_0
jupyter_console 6.0.0 py37_0
jupyter_core 4.6.1 py37_0
kiwisolver 1.1.0 py37h0a44026_0
lazy-object-proxy 1.4.3 py37h1de35cc_0
libarchive 3.3.3 h786848e_5
libcxx 4.0.1 hcfea43d_1
libcxxabi 4.0.1 hcfea43d_1
libedit 3.1.20181209 hb402a30_0
libffi 3.2.1 h475c297_4
libgfortran 3.0.1 h93005f0_2
libiconv 1.15 hdd342a3_7
liblief 0.9.0 h2a1bed3_2
libpng 1.6.37 ha441bb4_0
libsodium 1.0.16 h3efe00b_0
libtiff 4.1.0 hcb84e12_0
libxml2 2.9.9 hf6e021a_1
lz4-c 1.8.1.2 h1de35cc_0
lzo 2.10 h362108e_2
markupsafe 1.1.1 py37h1de35cc_0
matplotlib 3.1.1 py37h54f8f79_0
mccabe 0.6.1 py37_1
mistune 0.8.4 py37h1de35cc_0
mkl 2019.4 233
mkl-service 2.3.0 py37hfbe908c_0
mkl_fft 1.0.15 py37h5e564d8_0
mkl_random 1.1.0 py37ha771720_0
more-itertools 8.0.2 py_0
nbconvert 5.6.1 py37_0
nbformat 4.4.0 py37_0
ncurses 6.1 h0a44026_1
ninja 1.9.0 py37h04f5b5a_0
notebook 6.0.2 py37_0
numpy 1.18.1 py37h7241aed_0
numpy-base 1.18.1 py37h6575580_0
olefile 0.46 py37_0
openssl 1.1.1d h1de35cc_3
pandoc 2.2.3.2 0
pandocfilters 1.4.2 py37_1
parso 0.5.2 py_0
pcre 8.43 h0a44026_0
pexpect 4.7.0 py37_0
pickleshare 0.7.5 py37_0
pillow 7.0.0 py37h4655f20_0
pip 19.3.1 py37_0
pkginfo 1.5.0.1 py37_0
prometheus_client 0.7.1 py_0
prompt_toolkit 2.0.10 py_0
psutil 5.6.7 py37h1de35cc_0
ptyprocess 0.6.0 py37_0
py-lief 0.9.0 py37h1413db1_2
pycosat 0.6.3 py37h1de35cc_0
pycparser 2.19 py37_0
pygments 2.5.2 py_0
pylint 2.4.4 py37_0
pyopenssl 19.1.0 py37_0
pyparsing 2.4.6 py_0
pyqt 5.9.2 py37h655552a_2
pyrsistent 0.15.6 py37h1de35cc_0
pysocks 1.7.1 py37_0
python 3.7.6 h359304d_2
python-dateutil 2.8.1 py_0
python-graphviz 0.13.2 pypi_0 pypi
python-libarchive-c 2.8 py37_13
pytorch 1.4.0 py3.7_0 pytorch
pytz 2019.3 py_0
pyyaml 5.2 py37h1de35cc_0
pyzmq 18.1.0 py37h0a44026_0
qt 5.9.7 h468cd18_1
qtconsole 4.6.0 py_1
readline 7.0 h1de35cc_5
requests 2.22.0 py37_1
ripgrep 11.0.2 he32d670_0
ruamel_yaml 0.15.87 py37h1de35cc_0
send2trash 1.5.0 py37_0
setuptools 44.0.0 py37_0
sip 4.19.8 py37h0a44026_0
six 1.13.0 py37_0
soupsieve 1.9.5 py37_0
sqlite 3.30.1 ha441bb4_0
terminado 0.8.3 py37_0
testpath 0.4.4 py_0
tk 8.6.8 ha441bb4_0
torchvision 0.5.0 py37_cpu pytorch
torchviz 0.0.1 pypi_0 pypi
tornado 6.0.3 py37h1de35cc_0
tqdm 4.41.1 py_0
traitlets 4.3.3 py37_0
urllib3 1.25.7 py37_0
wcwidth 0.1.7 py37_0
webencodings 0.5.1 py37_1
wheel 0.33.6 py37_0
widgetsnbextension 3.5.1 py37_0
wrapt 1.11.2 py37h1de35cc_0
xz 5.2.4 h1de35cc_4
yaml 0.1.7 hc338f04_2
zeromq 4.3.1 h0a44026_3
zipp 0.6.0 py_0
zlib 1.2.11 h1de35cc_3
zstd 1.3.7 h5bba6e5_0

任何人都知道发生了什么,或者至少我在开发模式下安装的软件包会出现在哪里?

请注意,在使用 conda develop -u . 安装和卸载后,我的脚本现在可以工作了。但是我仍然不知道如何显示是否安装了开发模式下的包/项目。

最佳答案

如果你跑后仔细看conda develop . (setup.py 文件所在的位置)您会注意到该命令输出以下内容:

(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop .
added /Users/brandBrandoParetoopareto/ultimate-utils/uutils
completed operation for: /Users/brandBrandoParetoopareto/ultimate-utils/uutils

如果您然后检查 sys.path python有那么你可以添加新路径:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ python
Python 3.7.7 (default, Mar 26 2020, 10:32:53)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path:
... print(p)
...

/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python37.zip
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7/lib-dynload
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7/site-packages
/Users/brandBrandoParetoopareto/automl-meta-learning/automl
/Users/brandBrandoParetoopareto/higher
/Users/brandBrandoParetoopareto/ultimate-utils/uutils

您可以通过删除它并打印 sys.path 的内容来确认这一点。 :
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
uninstalled: /Users/brandBrandoParetoopareto/ultimate-utils/uutils

再次检查系统路径:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ python
Python 3.7.7 (default, Mar 26 2020, 10:32:53)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path:
... print(p)
...

/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python37.zip
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7/lib-dynload
/Users/brandBrandoParetoopareto/anaconda3/envs/automl/lib/python3.7/site-packages
/Users/brandBrandoParetoopareto/automl-meta-learning/automl
/Users/brandBrandoParetoopareto/higher

现在它不见了!

另外,请注意 conda 或 python(不确定哪个)也总是添加当前路径。这一点很重要,因为当我在 repo 之外进行导入测试时,我正在工作,但它不起作用,但它在 repo 内部,这看起来非常神秘,我只能归因于这一点。

附录

要从终端检查 python sys.path 将该命令作为带有 python cmd 的字符串运行:
python -c "import sys; print(sys.path)"

甚至更好:
python -c "import sys; [print(p) for p in sys.path]"

如果你想要一个别名:
alias pypath='python -c "import sys; [print(p) for p in sys.path]"'

把它放在你的 .zshrc .

旧答案

老实说,我知道的唯一方法就是尝试再次安装它。它通常说它已经在那里:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop .
path exists, skipping /Users/brandBrandoParetoopareto/ultimate-utils/uutils
completed operation for: /Users/brandBrandoParetoopareto/ultimate-utils/uutils

如果它说它已经存在但您的脚本仍然不起作用,请尝试安装和卸载:
conda develop -u .

输出应该是这样的:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
uninstalled: /Users/brandBrandoParetoopareto/ultimate-utils/uutils

然后再次尝试以开发/开发/开发人员模式安装它:
conda develop .

输出看起来像这样:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
uninstalled: /Users/brandBrandoParetoopareto/ultimate-utils/uutils

在哪里 。可以替换为项目根目录的路径(对我来说,它是 setup.py 所在的位置)。

笔记:

另一个测试是尝试卸载它两次。第二次它应该提示:
(importtest) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
uninstalled: /Users/brandBrandoParetoopareto/ultimate-utils/uutils
(importtest) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
conda.pth does not contain path: /Users/brandBrandoParetoopareto/ultimate-utils/uutils
package not installed via conda develop

仅供引用:如何在 pip 可编辑模式下卸载: How to uninstall editable packages with pip (installed with -e)

关于python - 如何检查 conda develop 是否安装了我的项目/包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59903548/

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