1 回答

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果您在運(yùn)行后仔細(xì)查看conda develop .(setup.py文件所在的位置),您會(huì)注意到該命令輸出以下內(nèi)容:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop .
added /Users/brandBrandoParetoopareto/ultimate-utils/uutils
completed operation for: /Users/brandBrandoParetoopareto/ultimate-utils/uutils
如果您然后檢查sys.pathpython,那么您可以添加新路徑:
(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
您可以通過(guò)刪除它并打印以下內(nèi)容來(lái)確認(rèn)這一點(diǎn)sys.path:
(automl) brandBrandoParetoopareto~/ultimate-utils/uutils $ conda develop -u .
uninstalled: /Users/brandBrandoParetoopareto/ultimate-utils/uutils
再次檢查系統(tǒng)路徑:
(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
現(xiàn)在它消失了!
另外,請(qǐng)注意 conda 或 python(不確定哪個(gè))也總是添加當(dāng)前路徑。需要注意這一點(diǎn)很重要,因?yàn)楫?dāng)我在 repo 之外進(jìn)行導(dǎo)入測(cè)試時(shí),我正在工作它并沒(méi)有工作,但它在 repo 內(nèi)部,這似乎非常神秘,我只能歸因于這一點(diǎn)。
附錄
從終端檢查 python sys.path 使用 python cmd 將該命令作為字符串運(yùn)行:
python -c "import sys; print(sys.path)"
更好:
python -c "import sys; [print(p) for p in sys.path]"
原始答案:https ://stackoverflow.com/a/59903590/1601580
添加回答
舉報(bào)