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.

QtConsole 4.3.0 ignores activated environment's kernel settings

See original GitHub issue

When launching QtConsole from an activated conda environment; sys.path, and sys.executable ignore the environment’s settings.

System, and version of conda, python, Qtconsole: Jupyter QtConsole 4.3.0 Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) IPython 6.1.0 – An enhanced Interactive Python. Type ‘?’ for help. platform : linux-64 conda version : 4.3.22 conda-env version : 4.3.22 conda-build version : not installed python version : 3.6.1.final.0

conda information within activated environment: (python_network) anna@linux:~> conda info -e CIO_TEST: <not set> CONDA_DEFAULT_ENV: python_network CONDA_ENVS_PATH: <not set> LD_LIBRARY_PATH: <not set> PATH:/home/anna/anaconda3/envs/python_network/bin:/home/anna/anaconda3/bin:/home/anna/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games PYTHONHOME: <not set> PYTHONPATH: <not set>

Verify in active environment, list available envs: (python_network) anna@linux:~> conda info -e conda environments:
python_network * /home/anna/anaconda3/envs/python_network
root /home/anna/anaconda3

List available kernels within activated env: (python_network) anna@linux:~> jupyter kernelspec list
Available kernels:
python3 /home/anna/anaconda3/envs/python_network/share/jupyter/kernels/python3

Launch Qtconsole using kernel parameter: (python_network) anna@linux:~> jupyter qtconsole --kernel=python3 import sys sys.path Out[2]: [‘’, ‘/home/anna/anaconda3/lib/python36.zip’, ‘/home/anna/anaconda3/lib/python3.6’, ‘/home/anna/anaconda3/lib/python3.6/lib-dynload’, ‘/home/anna/anaconda3/lib/python3.6/site-packages’, ‘/home/anna/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.6-py3.6.egg’, ‘/home/anna/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg’, ‘/home/anna/anaconda3/lib/python3.6/site-packages/IPython/extensions’, ‘/home/anna/.ipython’]

Its not using the path of the environment, so the modules installed within that environment but not the system as a whole are not available unless I change the path within Qtconsole each session

This sys.path and sys.executable is different than ipython if I lanuch from the same activated env: (python_network) anna@linux:~> ipython In [1]: import sys In [2]: sys.path Out[2]: [‘’, ‘/home/anna/anaconda3/envs/python_network/bin’, ‘/home/anna/anaconda3/envs/python_network/lib/python36.zip’, ‘/home/anna/anaconda3/envs/python_network/lib/python3.6’, ‘/home/anna/anaconda3/envs/python_network/lib/python3.6/lib-dynload’, ‘/home/anna/anaconda3/envs/python_network/lib/python3.6/site-packages’, ‘/home/anna/anaconda3/envs/python_network/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg’, ‘/home/anna/anaconda3/envs/python_network/lib/python3.6/site-packages/IPython/extensions’, ‘/home/anna/.ipython’]

I know there is a work around for jupyter notebook by installing nb_conda nb_conda_kernel, however that had no effect on jupyter Qtconsole, and I know of no other work around for qtconsole. Both Jupyter Notebook and ipython use the environment’s path but qtconsole does not.

I have found a crude work around by installing qtconsole into the environment itself, however, this doesn’t scale as environments become large just to test small libraries. It would be more ideal if qtconsole picked up the installed ipykernel settings installed into the environment.

I appreciate all the developer’s work on Jupyter and surrounding porjects, Thanks

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
annesessioncommented, Oct 24, 2017

I think this issue could be closed out after a small update in the documentation.

Publish your environment’s ipykernel to jupyter from within the activated environment after the ipykernel has been installed into the environment. The way http://ipython.readthedocs.io/en/stable/install/kernel_install.html is currently documented either doesn’t work, or creates a kernel.json file that points to default python, you want kernel.json to point explicitly to your environment’s python

Alternatively, change the kernel.json file of the kernel’s environment to point to python in your environment (not the default anaconda one)

For example, from within source activated environment python -m ipykernel install --user --name python_network --display-name "Python_Network"

In this case I’m installing it as a user so it will be installed /home/anna/.local/share/jupyter/kernels/python_network within this folder is a file called kernel.json. { "argv": [ "/home/anna/anaconda3/envs/python_networking/bin/python", "-m", "ipykernel_launcher", "-f", "{connection_file}" ], "display_name": "Python_Network", "language": "python" }

The argv parameter will give jupyter qtconsole (or console) the correct kernel interpreter and path for qtconsole.

Have the kernel advertised used by your environment to be something other than python3 (python_networking) anna@lapanna:~$ jupyter kernelspec list Available kernels: python_network /home/anna/.local/share/jupyter/kernels/python_network python3 /home/anna/anaconda3/envs/python_networking/share/jupyter/kernels/python3

In the above example the kernel.json in the anaconda3/envs/… is correct and points to the environment yet if launch juypter qtconsole --kernel=python3 qtconsole will ignore it and use conda default path instead.

TLDR:

  1. Install ipykernel at environment creation or install it as a module later,
  2. from within the activated environment after ipykernel install then advertise jupyter’s environment with python -m ipykernel install --user --name <env_name> --display-name "<display name>" 2a make sure the environments name listed juypter kernelspec list is something other than python3 2b explicitly add the kernel parameters when invoking qtconsole example. jupyter qtconsole --kernel=python_network
0reactions
takluyvercommented, Oct 24, 2017

If you remove installed Python kernelspecs (find them with jupyter kernelspec list), it will fall back to a default one running in the same environment as the frontend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration options — Jupyter Qt Console 4.3.0 ...
Set the kernel's IP address [default localhost]. If the IP address is something other than localhost, then Consoles on other machines will be...
Read more >
but not all – Cartopy maps with segmentation fault 11 - Stack ...
I can use Cartopy to successfully plot some maps but, in some cases, the Python kernel dies with Segmentation Fault 11. I wanted...
Read more >
Using Intel Distribution for Python in Spyder 3.6
Now you have to install spyder additionally for the new environment with this command (after the activation of the environment with the command...
Read more >
Jupyter Notebook Documentation - Elabs
with an active kernel have a Shutdown button next to them, ... The Jupyter Notebook is an interactive computing environment that enables ...
Read more >
Anaconda – Max Trinidad – The PowerShell Front
These tools give you the ability to use create Jupyter Notebook using Python Kernel but also with C#, F#, and PowerShell 7 kernels....
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