QtConsole 4.3.0 ignores activated environment's kernel settings
See original GitHub issueWhen 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:
- Created 6 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top GitHub Comments
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/python3In 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:
python -m ipykernel install --user --name <env_name> --display-name "<display name>"
2a make sure the environments name listedjuypter kernelspec list
is something other than python3 2b explicitly add the kernel parameters when invoking qtconsole example.jupyter qtconsole --kernel=python_network
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.