I am a bit of a newbie and made a virtualenvironment to connect to jutyer notebook as a kernel and I see the kernel when I open jp but cannot activate the virtual environment in the terminal.
To recreate what I had done
virtualenv myenv
source myenv/bin/activate
pip install --user ipykernel
pip install ipykernel
python -m ipykernel install --name=myenv
and now I get
$ source myenv/bin/activate
-bash: myenv/bin/activate: No such file or directory
and
lsvirtualenv -b
command not found
My available kernels are
myenv /Users/me/Library/Jupyter/kernels/myenv
Related
I get an error when running Jupyter Notebooks in VS code due to: ipykernel not installed in my_env
.
Running cells with 'Python 3.7.7 ('my_env')' requires ipykernel package.
Run the following command to install 'ipykernel' into the Python environment.
Command: 'conda install -n my_env ipykernel --update-deps --force-reinstall'
But I already have installed ipykernel in both base and my_env, and have already installed a new kernel in my_env following.
(base) user#username folderA % pip show ipykernel
Name: ipykernel
Version: 6.9.1
(my_env) user#username folderA % pip show ipykernel
Name: ipykernel
Version: 6.9.1
(my_env) user#username folderA % python -m ipykernel install --user --name=my_env
Also, when running the proposed conda install -n my_env ipykernel --update-deps --force-reinstall and reloading the window, the issue re-appears.
I have tried multiple solutions, like the proposed in sol1, sol2 and also pip install --upgrade jupyter_client, but nothing works.
I am using macOS with M1 chip and conda 23.1.0
Let me know if I need to add additional details.
I found a solution. The problem was related to my installation of jupyter in the selected environment.
I re-started from scratch in a new environment, and followed the below steps in order:
conda create env -n env_name python=3.XX
conda activate env_name
conda install jupyter
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=env_name
I want to install a package which is just used in one project.
So I create a virtual env and install it
python -m venv .venv --system-site-packages
python -m pip install my_package
Then I want to debug it with jupyter.
The problem is It seems I have to either install another jupyter in my virtual env ( quite large):
pip install jupyter
jupyter notebook
or register this env as a kernel to user:
python -m ipykernel install --user --name my_test_env
in this case, this env will list in my global kernel list but I won't use if for any other project. And delete the project folder will leave a broken kernel in global jupyter.
Is there any way to register a kernel just for current project?
Below step by step answer:
To install virtual environment using use below pip command:
py -m pip install --user virtualenv
Then create new environment:
py -m venv projectName
Then you have to activate your virtual environment:
.\projectName\Scripts\activate
Once done with activating virtual environment, You’ll see “(myproject)” next to the command prompt.
To install virtual environment using use below pip command:
py -m pip install --user virtualenv
Then create new environment:
py -m venv projectName
Then you have to activate your virtual environment:
.\projectName\Scripts\activate
Once done with activating virtual environment, You’ll see “(myproject)” next to the command prompt.
I'm trying to go to work with pipenv, but I have problems with the launch of the virtual environment.
errors:
➜ test_pipenv pipenv shell
Launching subshell in virtual environment…
. /home/user/.local/share/virtualenvs/test_pipenv-mzRyHdZF/bin/activate
➜ test_pipenv . /home/user/.local/share/virtualenvs/test_pipenv-mzRyHdZF/bin/activate
cd: **This is not a directory:** /home/user/.local/share/virtualenvs/test_pipenv-mzRyHdZF/bin/activate
or
➜ test_pipenv /home/user/.local/share/virtualenvs/venv-mzRyHdZF/bin/activate
zsh: **Access denied:** /home/user/.local/share/virtualenvs/venv-mzRyHdZF/bin/activate
or
➜ test_pipenv source /home/user/.local/share/virtualenvs/venv-mzRyHdZF/bin/activate
(test_pipenv) ➜ test_pipenv pip freeze
certifi==2018.10.15
chardet==3.0.4
idna==2.7
requests==2.19.1
urllib3==1.23
I installed the pipenv twice and get the same error:
sudo pip install pipenv
and
pip install --user pipenv
I get the same error
I use arch linux and zsh
.zshrc
export PATH=/usr/local/bin:$PATH
export SHELL=/bin/zsh
PIPENV_SHELL=/use/bin/zsh
export ZSH=/home/user/.oh-my-zsh
export PATH="$HOME/.local/bin:$PATH"
Help me please. Why does not it work pipenv shell?
Try doing this:
pip uninstall pipenv
this will uninstall existing pipenv
after doing that re-install pipenv by doing this:
pip install pipenv
check for permissions on your $HOME/.local/share/virtualenvs directory. If you are not allowed to create files/ directories in there, you cannot start a virtual env.
If you are In Arch Linux switch bash to fish.
Then run :
pipenv shell
(can't comment so I'll add this as an answer)
Hi,
From what I can tell you are doing all of this in terminal. If you do not have to work with pipenv, then I would recommend using virtualenv.
Install:
pip install virtualenv
Create a new virtual env:
virtualenv -p python3 your_env_name
load virtual env (from path where created file is located in):
source your_env_name/bin/activate
You can save your packages already installed with pip like this:
pip freeze > requirements.txt
and then load them in your virtual env (once you have loaded it) like this:
pip install -r requirements.txt
Hope this helps! :)
I currently use a Mac. I recently created a new python virtual environment and installed jupyter. When I activate jupyter notebook within the virtual environment, it says it cannot find any python kernels. I have another virtual environment that also has jupyter installed and it works perfectly fine. Can anyone help? Also, I'm not sure where the Kernels are even located on my machine. Library/Jupyter only has a runtime folder.
I need to do 2 things to get this to work:
conda install -y ipykernel
python -m ipykernel install --user --name myenv
Kind of frustrating and I never see it mentioned much in the docs. Jupyter set up remains a pretty painful process in my opinion. This is from beginning to end, if it helps anyone:
conda create -n myenv python=3.7
conda activate myenv
conda install -y -c conda-forge jupyterlab
conda install -y -c anaconda jupyter
conda install -y ipykernel
python -m ipykernel install --user --name myenv
Try installing nb_conda in your environment, by going to your command line conda activate your environment and conda install nb_conda. Make sure you also have ipykernel installed in your environment, then deactivate and reactivate your environment and try again.