python小白为了学习爬虫,在第一步就遇到了问题,记录一下解决办法
在windows下打开jupyter notebook时,首先是win+r打开控制台然后输入ipython notebook打开时会默认使用IE浏览器,但是只显示一个home不能打开使用,这是因为不支持该浏览器的原因。
1、win+r 然后输入jupyter notebook --generate-config
2、按照上面的路径找到jupyter_notebook_config.py,用能打开该文件的打开该文件
3、查找,browser,找到如下代码:
## Specify what command to use to invoke a web browser when opening the notebook.
# If not specified, the default browser will be determined by the `webbrowser`
# standard library module, which allows setting of the BROWSER environment
# variable to override it.
#c.NotebookApp.browser = u''
也有可能#c.NotebookApp.browser = u''这句没有u是这样#c.NotebookApp.browser = ''
4、在这句后面加上
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'))
c.NotebookApp.browser = 'chrome'
这里使用的是chrome浏览器,推荐使用,如果你使用火狐之类的也可以。
windows下地址一定是要用\\的不然不对。
另外如果还是不行可以考录改一下工作路径,或者觉得默认路径很麻烦的也可以改工作路径
5、更改工作路径
## Dict of Python modules to load as notebook server extensions.Entry values can
# be used to enable and disable the loading ofthe extensions. The extensions
# will be loaded in alphabetical order.
#c.NotebookApp.nbserver_extensions = {}
## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''
在这后面加上
c.NotebookApp.notebook_dir = 'D:\\anaconda\\nootbookwork'
路径自己决定就可以,没有特定要求。
记住路径中\一定要换成\\