-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jupyter Notebook is loading incorrect Python kernel #2563
Comments
Can you look at the |
|
This looks similar to jupyter/jupyter#270 . Ping @minrk - I think this is due to installing kernelspecs automatically as data files in the wheel. |
For now, you can probably work around it by changing the first item in |
Yup, it's the same. Running |
I didn't fully understand what @minrk said above, but running As @takluyver suggested, changing |
Solved this issue by executing python3 -m ipykernel install --user |
I also am experiencing this issue, and editing the two |
Hopefully not. We've refined this behaviour in a new version of |
This is also happening to me. Using |
works like charm |
My jupyter notebook was using a python3 kernel even though I wanted it to use a python2 kernel (and the web interface was showing python2).
|
This was my solution: |
works for me with python3 -m ipykernel install --user - THANK YOU nvdv 👍 |
Changing the executable path of jupyter (in the |
I'm having a similar issue on Mac OS. When trying to run the kernel within a virtual environment, the system python (brew installed) is loaded instead. When the virtualenv is active:
Likewise:
When running: The kernel.json file reads:
Changing the kernel.json path manually to the venv path does not fix the issue. When running a notebook, sys.executable still returns: Any ideas? |
Solved mine with |
as reported by others,
but from within jupyter lab,
so far, 2 solutions have been proposed, neither of which worked for me: Running
|
I opened /usr/local/share/jupyter/kernels/python2/kernel.json and rewrite the python path, but I couldn't save the file after that. I am using a server instead of stand alone OS, just in case this is the reason, if it is like this, do you have any idea please? |
The inability to save edits to a file directly is more of a system thing. You'll need to look at the |
Instead of changing kernel under /usr/local/share/jupyter/kernels/python3/kernel.json, the problem solved by modifying the kernel under ~/.local/share/jupyter/kernels/python3/kernel.json into |
solved my problem with |
I just recently started to get the exact same behaviour as @nicholas-miles - glad it's not only me. |
Were you in the activated environment (e.g., |
I use conda for my venvs, but yes. And doing |
Thanks @mathieuboudreau. I had seen that the When you say you recently started to get the exact same behavior, how recent are you talking about and were there any significant upgrades you may be aware of around that time as well? |
I was on vacation last week. If I recall, it was working correctly before then, and isn't working now. I don't think made any upgrades, but I could try and delete anaconda and reinstall it. |
I got the same issue! This is on Mac Catalina. |
You might find something helpful here and in the referenced links. |
Tested everything on https://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments still having the same issue as @nicholas-miles |
for the love of GOD, somebody please address this issue, none of the solutions work, and many have the same issue where changing the kernel does not point the python to the correct kernel environment. For me it always point into the same environment from which i ran the initial jupyter-notebook. I am stuck to that environment python, cannot change the kernel to any other one.
it points to the correct python environment and changes as expected, but |
It seems like the crux of the issue is that the correct python is in use by the kernel, but the PATH (from the kernel) doesn't reflect the python in use. As a result, while python statements (e.g., I found the IPython's documentation link in the Python Environments section of the troubleshooting documentation to be fairly helpful. In particular the portion about installing the kernel with the Jupyter, by default, doesn't activate environments for a given kernel. This is why the PATH-based commands (sans prefixing) can be problematic. If you find that activation may resolve things for you, then perhaps taking a look at nb_conda_kernels may be helpful. This package updates your jupyter's configuration to use an alternate Here's a screenshot of a kernel I've started that uses a python from an environment other than the notebook server. The notebook server is launched in my activated I hope you find this helpful and apologize for the frustration. |
I found this exact behavior when trying having
Is there any work around to install package diractly to |
Hi @yasirroni - try using the |
|
@jianboy I solved it with this
You may need to restart the kernel |
The problem with
For my setup with virtualenv it looks like this
In general:
|
@nemusa Thank you so much, this worked for me! It was driving me crazy that I couldn't figure out why the PATH inside the shell didn't match my $PATH |
@nemusa 's approach was the only thing that worked for me running the |
I am on OSX Sierra (10.12.5), and am using Jupyter Notebook v 4.3.0. I have installed both Python2 and Python3 using Homebrew, and both kernels for Jupyter Notebook. Upon opening the notebook to use Python3 kernel, I find that it still uses Python2.
I might be missing something obvious in my installation, but I can't seem to figure out what it is.
Detailed Description
Installation:
I installed both Python2 and Python3 using Homebrew, and Jupyter Notebook on my system thus:
brew install python3
pip3 install --upgrade pip3 setuptools wheel
pip3 install jupyter
I ran all analogous commands for Python2 as well.
Configuration:
I generated the config file using
jupyter notebook --generate-config
, and the only configurations I have "enabled" in my config file are:c.NotebookApp.browser = u'safari'
c.NotebookApp.password = 'sha1:somepwd'
Both kernels installed:
Both kernels seem to be visible to kernelspec:
Both kernels are also available as options when I start execute
jupyter notebook
:As an additional check,
pip list
andpip3 list
both includeipykernel
.Problem:
When I opened a new notebook using Python3 kernel, none of the packages I installed using
pip3
were recognized when I usedimport
. Furthermore,sys.path
returns path to Python2:When I run
print "Hello World"
, it gives me a successful output (which is true in Python2, but should throw an error in Python3).However, when I use the (depreciated) command
ipython3 notebook
, things work as expected:and all my Python3 packages are successfully recognized.
It doesn't seem to be the biggest deal breaker, as I can continue working with
ipython3 notebook
, but I wonder what I am missing that causesjupyter notebook
to not load Python3.The text was updated successfully, but these errors were encountered: