使用notebook 筆記(1),使用notebook筆記

來源:互聯網
上載者:User

使用notebook 筆記(1),使用notebook筆記
1 去開啟遠端存取notebook 注意事項

 

安裝好Ipython notebook 之後,  開啟服務的方式如下:

ipython notebook --profile=nbserver --ip=XXX.XXX.XXX PS :
  • --profile=nbserver  這個參數的值 可以寫成絕對路徑
  • ipython 命令也可以用jupyter 代替
  2 當遠端存取ipython  notebook 的時候, 發現輸入正確的密碼卻仍然不能進入;

在這種情況下,我們是通過攜帶token 參數來訪問的,

PS: 畢竟人家已經說了:Token authentication is enabled. You need to open the notebook server with its first-time login token in the URL, or enable a password in order to gain access. The command: :
  所以, 我們在終端繼續輸入 
jupyter notebook list
 
 

於是, 賦值其中一個, 粘貼到瀏覽器的地址欄中即可, 發現可以訪問了。 如下:

 

 

3 在python notebook 裡面建立notebook 的時候發現 很多第三方類庫是無法使用(例如 numpy)

 

說明: 我本地環境中的python 中是含有 numpy 和 tensorflow 的;但是在notebook 裡面去拋出:

ImportError                               Traceback (most recent call last)<ipython-input-14-4ee716103900> in <module>()----> 1 import numpy as npImportError: No module named 'numpy'

 

通過查閱資料發現問題的所在: ipython 只會載入自己所在的類庫目錄下 的第三方類庫, 而安裝到其他地方的類庫就無法載入了。

導致無法找到numpy 的問題原因是: numpy類庫無法讓python自動尋找到;

解決方案就是: 手動添加;

首先、 查詢numpy 第三方類庫所在的目錄:

在遠程終端中輸入:
python

>>>import numpy as np

>>>print(np.__file__)

輸出的是  ('/usr/python/lib/python3.5/site-packages/numpy/__init__.py')


 

 

好了 通過以上的命令我們知道了numpy 的安裝路徑;

於是乎, 可以在notebook手動載入到系統目錄中, 依次輸入:

import os

import sys

sys.path.append('/usr/python/lib/python3.5/site-packages/')

 


 

 

 

 

PS:

匯入這個路徑之後, 不僅僅numpy 可以用了,在這個目錄下的其他第三方類庫也可以使用了;

在此貼出 自己查詢的 資料:

http://stackoverflow.com/questions/15514593/importerror-no-module-named-when-trying-to-run-python-script/15622021#15622021

http://stackoverflow.com/questions/26238004/ipython-notebook-throws-importerror-ipython-doesnt

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.