2016-08-16 4044 views
2

我使用conda創建了一個名爲testEnv的環境並激活它,之後我使用命令jupyter notebook來調用jupyter編輯器。它的工作原理,但問題是,我只能在根環境中創建文件。我如何在testEnv環境中創建文件?如何在由conda創建的環境中啓動jupyter?

這裏是我做了什麼步驟:

$ conda create -n testEnv python=3.5 # create environmet 
$ source activate testEnv # activate the environmet 

(testEnv)$ jupyter notebook # start the jupyter notebook 

這裏有結果,這說明我只能在「testEnv」創建文件與「根」,但不是(只有Root,但沒有testEnv):

enter image description here

在標籤Conda,我可以看到testEnv,但我該如何切換呢?

enter image description here

+0

您是否嘗試過[這些答案](http://stackoverflow.com/questions/24117132/change-anaconda-ipython-main-directory)? – ragesz

+0

嗨@ragesz,這個答案是改變ipython的主目錄,但我只想使用jupyter作爲編輯環境 – xirururu

+1

@xirururu你必須安裝Jupyter到你想要使用它的每個環境中。 'conda創建-n testEnv python = 3.5筆記本' – darthbith

回答

2

您有兩種選擇。您可以安裝Jupyter筆記本到每個環境,並從該環境中運行的筆記本電腦:

conda create -n testEnv python=3.5 notebook 
source activate testEnv 
jupyter notebook 

,或者您需要從testEnv安裝IPython的內核到從中要運行Jupyter筆記本的環境。說明在這裏:http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments總結:

conda create -n testEnv python=3.5 
source activate testEnv 
python -m ipykernel install --user --name testEnv --display-name "Python (testEnv)" 
source deactivate 
jupyter notebook 
1

的答案是,你可能不應該這樣做。 Python virtualenvs和Conda環境旨在確定Python系統可用的資源,這些資源完全獨立於您的工作目錄。

只要具有相同的依賴關係,就可以使用相同的環境來處理多個項目。當你開始調整環境時,你開始搞亂通常自動維護的東西。

因此,您應該問自己的真正問題可能是「爲什麼我認爲將筆記本存儲在執行它們的環境中是個好主意。」

+0

我下載了anaconda但沒有安裝jupyter,它已經存在了...... – xirururu

+0

我只是說你應該將應用程序代碼保存在一個完全獨立於你用來處理它的環境的獨立區域。 – holdenweb

+0

是的,我將應用程序代碼保存在單獨的文件夾中,而不是在環境中。我已經跳進了一個單獨的文件夾,然後我實際上鍵入'jupyter notebook' – xirururu