Using Virtual Environments in Jupyter Notebook and Python

activate user virtualenv
>source yourenv/bin/activate

install ipykernel
>(yourenv) pip install --user ipykernel


Add you virtualenv to jupyter
>(yourenv) python -m ipykernel install --user --name=myenv

Then you can choose myenv to create new file.



key commands:
pip install --user ipykernel
python -m ipykernel install --user --name=myenv

pipenv command summarising.

referenced from :

install
$ pip install pipenv
$  brew install pipenv

make virtualenv
$ mkdir myenv
$ cd myenv
$ pipenv --python 3.6


install requirements pipenv
$ cd my_project
$ pipenv install

pipenv package install & uninstall
$ pipenv install beautifulsoup4
$  pipenv uninstall beautifulsoup4

freeze → pip freeze > "requirements.txt"
$ pipenv lock

install package to development version
$ pipenv install --dev pytest


install development version requirements 
$ pipenv install --dev

activate pipenv virtualenv
$ pipenv shell

deactivate pipenv virtualenv
$ exit


run pipenv without activate
$ pipenv run which python
$ pipenv run python my_project.py


Python interpreter setting in Visual studio code 

Making virtualenv using mkvirtualenv or virtualenv, simple command memo.


- create virtual env wrapper & deactivate
mkvirtualenv env-py2 -p python2 #(or python3)
workon env-py2
deactivate

- create virtual env & deactivate
sudo pip install virtualenv
virtualenv env
sourse env/bin/activate
source deactivate

- delete virtual env
rmvirtualenv envname

- virtualenv dependencies save and install
#On the first, save
pip freeze > requirements.txt
#On the second, install(note! after activating target env)
pip install -r requirements.txt

-show all virtualenv names
lsvirtualenv -l

- PyCharm virtualenv wrapper setting
We have to set directory path manually in preference setting page.
The path is like this in my case.
And then you can select this virtualenv on run/debug configuration.