This question has been covered previously on SO, but the recommended fixes didn't work.
I have installed Jupyter both with pip install jupyter --upgrade and macports port install py34-jupyter but I cannot access the command jupyter via the command line.
When executing pip install jupyter, the message is:
Requirement already satisfied: jupyter in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
This is also where pip is located. I have also tried
pip uninstall notebook
pip install notebook --upgrade
but this didn't work.
Inside /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages, I see:
jupyter-1.0.0-py3.4.egg-info
jupyter-1.0.0.dist-info
jupyter.py
jupyter_client
jupyter_client-4.4.0-py3.4.egg-info
jupyter_client-4.4.0.dist-info
jupyter_console
jupyter_console-5.0.0-py3.4.egg-info
jupyter_console-5.0.0.dist-info
jupyter_core
jupyter_core-4.2.0.dist-info
jupyter_core-4.2.1-py3.4.egg-info
I thought perhaps it was possible that the command jupyter does not have the correct path to the executable necessary, but this doesn't appear to be the case.
How can I have access to jupyter notebook?
If you are using python on mac, I would strongly recommend using a virtualenv and installing all your dependencies using that. Had issues with installing and using several libraries.
pip install virtualenv virtualenvwrapper
# Create a backup of your .bash_profile
cp ~/.bash_profile ~/.bash_profile-org
# Be careful with this command
printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' \
'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bash_profile
source ~/.bash_profile
mkdir -p $WORKON_HOME
mkvirtualenv your_virtual_env
This creates the virtual environment
deactivate
When you are out of virtual env, you can uninstall jupyter from your machine using pip uninstall jupyter
workon your_virtual_env
pip install jupyter
Related
My Jupyter Notebook will say connecting to kernel before not being able to make a connection.
To correct this I run.
python -m pip --proxy http://my_proxy_chain install --upgrade notebook
But while installing that, while it's collecting pywinpty>=1.1.0, I get:
ERROR: No matching distribution found for maturin<0.13,>=0.12.6
What troubleshooting steps should I attempt to get jupyter notebook talking to the kernel? I already installed maturin after getting this error - but that does not change the effect of getting it when I try to upgrade my notebook.
Try these steps;
create new environment using venv or conda env create -name <YOUR_ENV_NAME>
install dependancies. (You can even use pip install -r requirements.txt
for the jupyter kernel setup;
pip3 install jupyter ipykernel
python3 -m ipykernel install --user --name=new_kernel
new_kernel is the name of the kernel you need to select in the Jupyter notebook
I created a test folder and then did pipenv install inside this test folder.
After that, I ran pipenv shell to activate my new environment.
So far so good...
And then I ran pip freeze
There's no jupyter in this just created virtual machine, but if I type jupyter notebook, it opens jupyter o_O
On the jupyter notebook I ran import sys and then print(sys.executable) to check if the environment is fine, but it's actually running my global environment outside the pipenv. Although, it's running the correct Python on !which python command.
Can anyone please tell me what I have to do to have a pipenv environment isolated (encapsulated) to work on different projects?
First of, the typical workflow with pipenv and installing packages is:
Setup system-wide python and virtual environment module (i.e. pipenv)
Create your project folder (i.e. test)
Create a virtual environment there (i.e. pipenv shell or pipenv install)
You can pass in a specific python version (important if you have multiple installed)
With pipenv, pass --python=/path/to/python3
Install your packages (i.e. pipenv install jupyter)
Now for jupyter. When you install it, it adds a bin/jupyter executable. Since you already have it installed with your system-wide python, then it also becomes available system-wide (even inside a pipenv shell).
~$ python3.8 -m pip install jupyter
...
Requirement already satisfied: jupyter in /usr/local/lib/python3.8/site-packages (1.0.0)
~$ which jupyter
/usr/local/bin/jupyter
~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Invoking jupyter should find it in /usr/local/bin. Inside a pipenv shell, it does not block you from accessing system-wide bin things (because that would be annoying). So inside a pipenv shell, your jupyter installation is still available:
TEMP$ pipenv shell
(TEMP) TEMP$ pip list
Package Version
---------- -------
pip 20.2.4
setuptools 50.3.2
wheel 0.35.1
(TEMP) TEMP$ echo $PATH
/Users/me/.venvs/TEMP-S6DFgeUE/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(TEMP) TEMP$ which jupyter
/usr/local/bin/jupyter
(TEMP) TEMP$ jupyter --version # Can be invoked here even if not in pip list
What the pipenv shell does is prepend another /bin folder at the front of your $PATH, so packages you install inside this env and add bin things will be accessible. Invoking them should find it first from the virtual environment. What happened to you is that invoking jupyter did not find it inside the virtual environment's bin (/Users/me/.venvs/TEMP-S6DFgeUE/bin), but in the system-side bin (/usr/local/bin). That is why even without installing jupyter in your virtual environment, it is still accessible.
This generally applies to packages that install bin things.
Now, what to do. As I mentioned at the start, you should (as much as possible) avoid installing things in the system-wide python. Only install things (as much as possible) inside a virtual environment.
So, for your case, start with installing jupyter inside your virtual environment:
(TEMP) TEMP$ pipenv install jupyter
Installing jupyter...
...
(TEMP) TEMP$ which jupyter
/Users/me/.venvs/TEMP-S6DFgeUE/bin/jupyter
(TEMP) TEMP$ jupyter --version # Check that it works
(TEMP) TEMP$ ls $(pipenv --venv)/lib/python3.8/site-packages | grep jupyter
jupyter-1.0.0.dist-info
jupyter.py
jupyter_client
jupyter_client-6.1.7.dist-info
jupyter_console
jupyter_console-6.2.0.dist-info
jupyter_core
jupyter_core-4.7.0.dist-info
jupyterlab_pygments
jupyterlab_pygments-0.1.2.dist-info
When you install it, invoking jupyter should now find it from the virtual environment bin. It should also add the jupyter things in the virtual environment's site-packages folder.
To confirm that your jupyter in your virtual environment is working, I highly recommend uninstalling the system-wide jupyter. Note that it's not enough to just do pip uninstall jupyter, you need to uninstall it completely to remove the /usr/local/bin/jupyter (see: How to uninstall jupyter):
python3.8 -m pip uninstall -y jupyter jupyter_core jupyter-client jupyter-console jupyterlab_pygments notebook qtconsole nbconvert nbformat
Then go back to your pipenv shell, and confirm that you only have jupyter inside your virtual environment:
~$ jupyter --version
-bash: jupyter: command not found
~$ cd TEMP
TEMP$ pipenv shell
Launching subshell in virtual environment...
...
(TEMP) TEMP$ jupyter --version
jupyter core : 4.7.0
jupyter-notebook : 6.1.5
qtconsole : 5.0.1
ipython : 7.19.0
ipykernel : 5.3.4
jupyter client : 6.1.7
jupyter lab : not installed
nbconvert : 6.0.7
ipywidgets : 7.5.1
nbformat : 5.0.8
traitlets : 5.0.5
(TEMP) TEMP$ which jupyter
/Users/me/.venvs/TEMP-S6DFgeUE/bin/jupyter
I trying to use virtualenv on jupyter notebook, to use all packages installed in an environment, but inside jupyter they are not recognized.
Already tried:
pip install tornado==4.5.3
pip install ipykernel==4.8.2
What I do is:
Initializing the environment on prompt (windows 7):
Move to directory of environment: cd C:\Python\Envs\env1\Scripts
and use: activate now the promt show (env1), so it's active.
From there, I move to another directory and call jupyter, but when starts, the package installed on envoriment are not callable.
How we can active the environment on jupyter?
Maybe you should install an ipykernel inside your venv first.
virtualenv .venv
.venv\Scripts\activate.bat to activate the venv.
pip install ipykernel
ipykernel install --user --name .venv to install a new kernel named .venv.
jupyter notebook here and you can select your new kernel.
REFERENCE: Kernels for different environments
for Max/Linux users:
python -m venv venv
source venv/bin/activate
pip install jupyter
ipython kernel install --user --name=venv
jupyter notebook
I have both the version of python.I have also installed jupyter notebook individually and when i open the jupyter notebook and go to new section it is showing python 2
I want to use python3 for newer packages.So how can we upgrade the python version.
More systematic approach would be
1 Install virtualenvwrapper
$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv -p $(which python3) jupyter_notebook
2 Install jupyter in this environment
(jupyter_notebook)$ pip install jupyter
3 Run notebook
(jupyter_notebook)$ jupyter notebook
4 To install new packages don't forget to activate newly created virtual environment
$ workon jupyter_notebook
(jupyter_notebook)$ pip install numpy
If the kernel was not visible in the kernel options you will have to configure it manually. This is how I did it on my macos.
python3 -m pip install ipykernel
python3 -m ipykernel install --user
After running these commands you should be able to see the kernel in the change kernel option.
I tried to install Jupyter on my Mac (10.9).
Since I'm using a computer at the university and don't have permission to write in /usr/local/bin, I downloaded Ipython from GitHub and typed python3.4 setup.py install --user on Terminal.
Though I didn't get any error while installing, Jupyter does not launch when I type ipython notebook (ipython3 notebook or jupyter were the same) and I got command not found error.
(I also tried to install via pip. However, pip does not work on my computer and I couldn't activate it using ensurepip.)
Why does pip not work? (insufficient privileges to write into system packages)?
Have you tried a virtual environments Creation of virtual environments? They are very useful for managing your environment so that you have local packages and a local bin folder for things like ipython:
$ python3 -m venv my_venv
$ source my_venv/bin/activate
$ pip install ipython[all]
This will install into your my_venv environment.