question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Differing IPython and Jupyter behaviour in virtualenvs

See original GitHub issue

It seems that the ~/.ipython/profile_default/startup/... files are executed in a different environment depending on whether I invoke ipython or jupyter console in a virtualenv.

I have a Python package installed in my system site packages and in a virtualenv (in two different versions). If I invoke ipython, it seems that sys.path is adjusted for the virtualenv first before the startup file is executed and the correct package is loaded. However, with jupyter console (also in the virtualenv) it seems that the startup file is executed (loading the wrong package in system site packages) and then the path is adjusted. Upon executing the first command it appears the startup file is executed again, but because the package was already loaded it won’t be replaced with the correct version.

Installing jupyter in the virtualenv fixes this problem, but I am wondering: What is the intended behaviour? (It would be convenient if it was not necessary to install jupyter in every virtualenv.) Is the different behaviour of the ipython and jupyter command intended?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
takluyvercommented, Dec 12, 2016

You can do it using a startup file - see ipython/ipykernel#96 for more discussion.

0reactions
phejimlincommented, Dec 12, 2016

Sorry, It’s there any way to set jupyter notebook auto add the virtualenv to sys.path even if jupyter itself is installed outside virtualenv? Now, I just can sys.path.append(virtualenv path) to work around.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run a new Jupyter Notebook in an already existing virtual ...
Install a Jupyter kernel in your virtual environment with the following command: ipython kernel install --user --name=venv. Where --user limits the install ...
Read more >
Using Virtual Environments in Jupyter Notebook and Python
Are you working with Jupyter Notebook and Python? Do you also want to benefit from virtual environments? In this tutorial you will see...
Read more >
Calling IPython from a virtualenv - Stack Overflow
This is a great way of always being sure that the ipython instance always belongs to the virtualenv's python version.
Read more >
Configuring user environments - JupyterHub - Read the Docs
This section will focus on user environments, which includes the following: Installing packages. Configuring Jupyter and IPython. Installing kernelspecs. Using ...
Read more >
Use Virtual Environments Inside Jupyter Notebooks & Jupter ...
They allow you to work on multiple python projects at the same time, without one accidentally corrupting the dependencies of another. While using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found