如何查看在开发模式下安装的包?我尝试了conda list
,但它没有显示任何熟悉的内容。
我运行了conda develope代码>并且似乎是它安装的:
(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'
但是当我做康达清单时,我看不到任何我认识的东西:
(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
有人知道发生了什么,或者至少知道我在开发模式下安装的软件包会出现在哪里吗?
请注意,在使用condadevelope-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的内容来确认这一点。路径
:
(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(不确定是哪一个)也总是添加当前路径。这一点值得注意,因为当我在回购之外进行导入测试时,我正在工作,但它不工作,而是在回购内部,这似乎非常神秘,我只能归因于此。
检查python sys。终端的路径使用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可编辑模式下卸载:如何使用pip卸载可编辑软件包(随-e一起安装)