How to get ipywidgets working in Jupyter Lab?

JupyterLab now prefers a model where arbitrary javascript is no longer allowed to be embedded in a cell’s output, which is how many interactive Jupyter Notebook modules used to work. They now ask that modules with interactivity create a JupyterLab extension. ipywidgets provides @jupyter-widgets/jupyterlab-manager extension which satisfies this requirement. When using ipywidgets 7.6 or newer … Read more

Can I run Jupyter notebook cells in commandline?

nbconvert (a jupyter tool for notebook conversion) allows you to do this without any extra packages: Just go to your terminal and type $ jupyter nbconvert –to notebook –inplace –execute mynotebook.ipynb Source (Thanks Stephan for suggesting the –inplace flag) NOTE: This said, I’d try to convert everything you need to a proper script. Jupyter notebooks … Read more

jupyter notebook running kernel in different env

This is a tricky part of ipython / Jupyter. The set of kernels available are independent of what your virtualenv is when you start jupyter Notebook. The trick is setting up the the ipykernel package in the environment you want to identify itself uniquely to jupyter. From docs on multiple ipykernels, source activate ENVNAME pip … Read more

Execute Python script within Jupyter notebook using a specific virtualenv

Here’s what worked for me (non conda python): (MacOS, brew version of python. if you are working with system python, you may (will) need prepend each command with sudo) First activate virtualenv. If starting afresh then, e.g., you could use virtualenvwrapper: $ pip install virtualenvwrapper $ mkvirtualenv -p python2 py2env $ workon py2env # This … Read more

how to make a new line in a jupyter markdown cell

Just add <br> where you would like to make the new line. $S$: a set of shops <br> $I$: a set of items M wants to get Because jupyter notebook markdown cell is a superset of HTML. http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Working%20With%20Markdown%20Cells.html Note that newlines using <br> does not persist when exporting or saving the notebook to a pdf … Read more

How do I set up Jupyter/IPython Notebook for Django?

Install django-extensions from https://github.com/django-extensions/django-extensions/blob/master/docs/index.rst pip install django-extensions Change your settings file to include ‘django-extensions’ INSTALLED_APPS += [‘django_extensions’] Run your Django server like this: python manage.py shell_plus –notebook alter to suit, and run this in your first cell import os, sys PWD = os.getenv(‘PWD’) os.chdir(PWD) sys.path.insert(0, os.getenv(‘PWD’)) os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “local_settings.py”) import django django.setup() Now you should be … Read more

How do I find the name of the conda environment in which my code is running?

You want $CONDA_DEFAULT_ENV or $CONDA_PREFIX: $ source activate my_env (my_env) $ echo $CONDA_DEFAULT_ENV my_env (my_env) $ echo $CONDA_PREFIX /Users/nhdaly/miniconda3/envs/my_env $ source deactivate $ echo $CONDA_DEFAULT_ENV # (not-defined) $ echo $CONDA_PREFIX # (not-defined) In python: import os print(os.environ[‘CONDA_DEFAULT_ENV’]) for the absolute entire path which is usually more useful: Python 3.9.0 | packaged by conda-forge | (default, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)