簡體   English   中英

在 Jupyer Notebook 中找不到來自 Conda env 的軟件包

[英]Packages from Conda env not found in Jupyer Notebook

我創建了一個名為 imagescraper 的環境並用它安裝了 pip。

然后我繼續使用 pip 安裝一個名為 ImageScraper 的包;

>>activate imagescraper
[imagescraper]>>pip install ImageScraper

只是為了確保我成功安裝了軟件包:

>>conda list

[imagescraper] C:\Users\John>conda list
# packages in environment at C:\Anaconda2\envs\imagescrap
#
future                    0.15.2                    <pip>
imagescraper              2.0.7                     <pip>
lxml                      3.6.0                     <pip>
numpy                     1.11.0                    <pip>
pandas                    0.18.0                    <pip>
pip                       8.1.1                    py27_1
python                    2.7.11                        4
python-dateutil           2.5.2                     <pip>
pytz                      2016.3                    <pip>
requests                  2.9.1                     <pip>
setproctitle              1.1.9                     <pip>
setuptools                20.3                     py27_0
simplepool                0.1                       <pip>
six                       1.10.0                    <pip>
vs2008_runtime            9.00.30729.1                  0
wheel                     0.29.0                   py27_0

在我啟動 Jupyter notebook 之前,只是為了檢查我們從哪里獲取路徑:

[imagescraper] C:\Users\John>python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:58:36) [MSC
v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import sys
>>> sys.executable
'C:\\Anaconda2\\envs\\imagescraper\\python.exe'
>>> import image_scraper

看起來不錯,所以我繼續使用

[imagescraper]>>jupyter notebook

在筆記本中,我創建了一本新書,當我嘗試相同時;

import image_scraper

我返回:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-6c2b65c9cdeb> in <module>()
----> 1 import image_scraper

ImportError: No module named image_scraper

用同樣的方法檢查 Jupyter notebook 中的路徑,我明白了;

import sys

sys.executable

'C:\\Anaconda2\\python.exe'

這告訴我它不是指我安裝模塊的環境。

有沒有辦法確保我的筆記本都引用它自己的 env 包?

以下是兩種可能的解決方案:

您可以根據您的imagescraper環境注冊一個新內核。 內核將從imagescraper環境啟動,從而看到它的所有包。

source activate imagescraper
conda install ipykernel
ipython kernel install --name imagescraper

這將向您的 jupyter 儀表板添加一個名為imagescraper的新內核。


另一種解決方案是將 jupyter notebook 安裝到imagescraper環境中,並從該環境中啟動 jupyter。 這需要在您啟動 jupyter notebook 時激活imagescraper

source activate imagescraper
conda install notebook
jupyter notebook

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM