jupyter-notebook

How to call a fucntion from a .py file in Jupyter Notebook?

会有一股神秘感。 提交于 2020-03-26 03:51:19
问题 I don't want to write the same function in each Jupyter Notebook files. It would be easier if I just need to edit the function once without the need to edit in each .ipynb file. The problem is, I have to restart kernel if I edit the .py file which will re-start everything. Is there any way I can simply call a function from several .pynb files? PS: After I have edited the .py, it does not affect the .ipynb file. 回答1: Yes, you need a make .py file with function defined and import that file then

Launch Juypter in Mac

这一生的挚爱 提交于 2020-03-25 18:19:41
问题 I tried to follow this doc to launch jupyter in my Mac, but it did not work. Could anyone help? Ties-MBP:10studio-4 chengtie$ pip --version pip 19.0.1 from /Library/Python/2.7/site-packages/pip (python 2.7) Ties-MBP:10studio-4 chengtie$ jupyter --version 4.4.0 Ties-MBP:10studio-4 chengtie$ pip install notebook DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will

Redirect STDOUT and STDERR to python logger and also to jupyter notebook

吃可爱长大的小学妹 提交于 2020-03-25 16:06:45
问题 Important to know: I am working on jupyter notebook. I want to create a logger to which I will redirect the STDOUT and STDERR but I also want to see those outputs on the jupyter notebook output console. So far what I have implemented is: import logging import sys class StreamToLogger(object): """ Fake file-like stream object that redirects writes to a logger instance. """ def __init__(self, logger, log_level=logging.INFO): self.logger = logger self.log_level = log_level self.linebuf = '' def

Jupyter notebook: how to leave one cell out while 'run all'

て烟熏妆下的殇ゞ 提交于 2020-03-25 16:05:49
问题 I'm writing python using jupyter notebook and I have two cells that can influence each other. I'm wondering is it possible to leave some certain cells out after I click Restart & Run All so that I can test the two cells independently? 回答1: One option based on Davide Fiocco's answer of this post and that I just tested is to include %%script magic command on each cell you don't want to execute. For example %%script false --no-raise-error for i in range(100000000000000): print(i) 回答2: If you put

Error 13 When trying to run my Jupyter Notebook

你说的曾经没有我的故事 提交于 2020-03-24 09:42:11
问题 I am not sure what happened but I am no longer able to run my Jupyter notebooks. I am getting the following error Traceback (most recent call last): File "C:\Users\asher\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute result = await result File "C:\Users\asher\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run yielded = self.gen.throw(*exc_info) # type: ignore File "C:\Users\asher\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in

Is there a way to toggle cell output in Jupyter Lab?

主宰稳场 提交于 2020-03-23 12:34:36
问题 In Jupyter Notebook you can toggle the cell output by going into command mode and pressing "O". This command does not work on Jupyter Lab, and I don't see an option to add it. Is there a way to do this, even if it means writing the code for the command? 回答1: As Arkady said, this looks like a duplicate from this post. Note, you can also do this in the sidebar if you don't want to code it. 来源: https://stackoverflow.com/questions/57009598/is-there-a-way-to-toggle-cell-output-in-jupyter-lab

Multiprocessing on Python 3 Jupyter

主宰稳场 提交于 2020-03-22 07:04:48
问题 I come here because I have an issue with my Jupiter's Python3 notebook. I need to create a function that uses the multiprocessing library. Before to implement it, I make some tests. I found a looooot of different examples but the issue is everytime the same : my code is executed but nothing happens in the notebook's interface : The code i try to run on jupyter is this one : import os from multiprocessing import Process, current_process def doubler(number): """ A doubling function that can be

Multiprocessing on Python 3 Jupyter

為{幸葍}努か 提交于 2020-03-22 07:03:29
问题 I come here because I have an issue with my Jupiter's Python3 notebook. I need to create a function that uses the multiprocessing library. Before to implement it, I make some tests. I found a looooot of different examples but the issue is everytime the same : my code is executed but nothing happens in the notebook's interface : The code i try to run on jupyter is this one : import os from multiprocessing import Process, current_process def doubler(number): """ A doubling function that can be

Jupyter Notebooks not displaying progress bars

我的梦境 提交于 2020-03-21 22:01:09
问题 I'm trying to get a progress bar going in Jupyter notebooks. This is a new computer and what I normally do doesn't seem to work: from tqdm import tqdm_notebook example_iter = [1,2,3,4,5] for rec in tqdm_notebook(example_iter): time.sleep(.1) Produces the following text output and doesn't show any progress bar HBox(children=(IntProgress(value=0, max=5), HTML(value=''))) Similarly, this code: from ipywidgets import FloatProgress from IPython.display import display f = FloatProgress(min=0, max=1

Jupyter Notebooks not displaying progress bars

我怕爱的太早我们不能终老 提交于 2020-03-21 21:58:50
问题 I'm trying to get a progress bar going in Jupyter notebooks. This is a new computer and what I normally do doesn't seem to work: from tqdm import tqdm_notebook example_iter = [1,2,3,4,5] for rec in tqdm_notebook(example_iter): time.sleep(.1) Produces the following text output and doesn't show any progress bar HBox(children=(IntProgress(value=0, max=5), HTML(value=''))) Similarly, this code: from ipywidgets import FloatProgress from IPython.display import display f = FloatProgress(min=0, max=1