問題描述
我正在用 Python 開發(fā)一個(gè)項(xiàng)目,我想包含一些自己的模塊,這些模塊不在常規(guī) Python 搜索路徑中,我想添加它們.但是,我只想為我在開發(fā)期間使用的 Anaconda 環(huán)境執(zhí)行此操作,并且我希望它們隨著時(shí)間的推移保持在那里(即,當(dāng)我重新啟動(dòng)環(huán)境時(shí),我希望搜索路徑具有該文件夾).
I am developing a project in Python and I want to include some own modules which are not on the regular Python search path and I want to add them. However, I want to do this just for the Anaconda environment I am using during development and I would like them to remain there over time(i.e. when I restart the environment, I want the search path to have that folder).
謝謝!
推薦答案
可以用
conda develop <directory>
這會(huì)將 conda.pth
文件寫入環(huán)境的 site-packages 目錄,這將導(dǎo)致您的目錄添加到 sys.path
.
This will write a conda.pth
file to the environment's site-packages directory which will cause your directory to be added to the sys.path
.
這篇關(guān)于如何將文件夾添加到給定 Anaconda 環(huán)境的搜索路徑?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!