2016-04-03 12 views
7

Ho creato un ambiente chiamato imagescraper e installato pip con esso.Pacchetti da Conda env non trovati in Jupyer Notebook

Procedere quindi a utilizzare pip per installare un pacchetto denominato ImageScraper;

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

solo per garantire che ho il pacchetto installato con successo:

>>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 

Prima mi lancio Jupyter notebook, solo per controllare dove stiamo ottenendo il percorso da:

[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 

Sembra ok, quindi procedo a lanciare il taccuino Jupyter usando

[imagescraper]>>jupyter notebook 

All'interno del notebook ho creato un nuovo libro e quando ho provato lo stesso;

import image_scraper 

Io sono tornato con:

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

ImportError: No module named image_scraper 

Fare la stessa per controllare i percorsi all'interno Jupyter notebook, ottengo questo;

import sys 

sys.executable 

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

Il che mi dice che non si riferisce all'ambiente in cui ho installato i moduli in.

C'è un modo posso assicurare che i miei quaderni riferiscono tutti ai propri pacchetti env?

+2

sì, si: installa un ipykernel nell'ambiente 'imagescraper'. Puoi usare la mia risposta qui come modello: http://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook/. Oppure: installa jupyter nell'ambiente 'imagescraper' e avvia jupyter da questo ambiente. – cel

+0

grazie che ha funzionato per me! – BernardL

+2

@cel dovresti espanderlo in una risposta :-) –

risposta

11

Qui ci sono due possibili soluzioni:

È possibile registrare un nuovo kernel basato sul imagescraper ambiente. Il kernel inizierà dall'ambiente imagescraper e quindi vedrà tutti i suoi pacchetti.

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

Questo aggiungerà un nuovo kernel di nome imagescraper al cruscotto jupyter.


Un'altra soluzione è quella di installare notebook jupyter nell'ambiente imagescraper e iniziare jupyter dalla ambiente. Ciò richiede l'attivazione di imagescraper ogni volta che si avvia jupyter notebook.

source activate imagescraper 
conda install notebook 
jupyter notebook 
+0

Grazie! In qualche modo preferisco installare solo jupyter in tutti i miei envs separati. Funziona come un fascino. – BernardL