{"id":29604625,"url":"https://github.com/bhrutledge/jupyter-venv","last_synced_at":"2025-07-20T15:37:47.238Z","repository":{"id":24499990,"uuid":"101767266","full_name":"bhrutledge/jupyter-venv","owner":"bhrutledge","description":"Jupyter Notebooks and Virtual Environments","archived":false,"fork":false,"pushed_at":"2023-06-05T14:16:41.000Z","size":224,"stargazers_count":21,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T23:27:29.011Z","etag":null,"topics":["jupyter","jupyter-notebook","python","venv","virtual-environments","virtualenv"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhrutledge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-29T13:56:45.000Z","updated_at":"2022-12-14T22:44:17.000Z","dependencies_parsed_at":"2023-01-14T01:05:11.547Z","dependency_job_id":null,"html_url":"https://github.com/bhrutledge/jupyter-venv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bhrutledge/jupyter-venv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fjupyter-venv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fjupyter-venv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fjupyter-venv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fjupyter-venv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhrutledge","download_url":"https://codeload.github.com/bhrutledge/jupyter-venv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fjupyter-venv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266151573,"owners_count":23884443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter","jupyter-notebook","python","venv","virtual-environments","virtualenv"],"created_at":"2025-07-20T15:37:46.557Z","updated_at":"2025-07-20T15:37:47.232Z","avatar_url":"https://github.com/bhrutledge.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jupyter Notebooks and Virtual Environments\n\nRun one notebook server per user, but allow notebooks to be created in multiple Python virtual environments.\n\n## Install Jupyter\n\n**Note**: If you're using the Anaconda distribution of Python, you can probably skip this step, and just run `jupyter notebook` in the default environment.\n\nClone this repo, then install Jupyter and useful tools like Pandas into a virtual environment:\n\n```sh\npython3 -m venv venv\n\nsource venv/bin/activate\n\npip install -U setuptools wheel pip pip-tools\n\npip-sync\n\njupyter nbextension enable --py --sys-prefix widgetsnbextension\n\njupyter labextension install @jupyter-widgets/jupyterlab-manager\n```\n\nRun the notebook server in your home directory:\n\n```sh\njupyter notebook --notebook-dir $HOME\n```\n\nYou should now see the Jupyter Notebook application in your web browser, showing the contents of your home directory. To create a notebook, navigate to the directory where you'd like to save it, then click `New`.\n\nYou can also run JupyterLab:\n\n```sh\njupyter lab --notebook-dir $HOME\n```\n\n## Run as a service on macOS\n\n```sh\n./load_launch_agent.sh\n```\n\nThis will write a `.plist` file to run the notebook server at \u003chttp://localhost:8888\u003e, then show the contents of the log file. Typing `Ctrl-C` will return to the prompt, but leave the server running. When you reboot, the server will start automatically.\n\nFor JupyterLab, running at \u003chttp://localhost:8889\u003e:\n\n```sh\n./load_launch_agent.sh lab 8889\n```\n\n## Creating notebooks for a virtual environment\n\nIn a new shell session, activate the virtual environment for one of your projects, and install an IPython kernel:\n\n```bash\ncd ~/path/to/my-project\n\nsource venv/bin/activate\n\npip install ipykernel\n\npython -m ipykernel install --user --name=${PWD##*/}\n\ndeactivate\n```\n\n- **NOTE**: The `ipykernel` package should be added to the project's `requirements.txt`\n\nOn macOS, this will create a Jupyter kernel spec in `$HOME/Library/Jupyter/kernels/my-project`. You can edit `kernel.json` in that directory to set environment variables or pass additional arguments to `python`.\n\nReload your Jupyter Notebook browser tab, then use `New \u003e my-project` to create a notebook. You can now use all of the packages that are installed in the `my-project` environment. However, this means you can't use the packages in the `jupyter-venv` environment, used by the default `Python 3` kernel. If you want to use packages like Pandas or matplotlib, you'll need to `pip install` them in the `my-project` environment (ideally by adding them to its `requirements.txt`).\n\n## Reference\n\n- [Enabling ipywidgets](https://ipywidgets.readthedocs.io/en/stable/user_install.html)\n- [Using a virtualenv in an IPython notebook](http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs)\n- [Installing the IPython kernel](https://ipython.readthedocs.io/en/latest/install/kernel_install.html)\n- [Making kernels for Jupyter](https://jupyter-client.readthedocs.io/en/latest/kernels.html)\n\n## TODO\n\n- Document rationale for one notebook server per user vs. running `jupyter notebook` in project's virtual environment (see [related issue](https://github.com/bhrutledge/jupyter-venv/issues/1))\n- `Makefile` or shell script for creating virtual environment, adding kernel, updating requirements, installing service\n- Use configuration file to set root notebook directory\n- Add a `supervisord` configuration?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhrutledge%2Fjupyter-venv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhrutledge%2Fjupyter-venv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhrutledge%2Fjupyter-venv/lists"}