I'm creating the Jupyter kernel within the virtual environment but the pkg in Juypter notebook is still missing after pip install
            Asked
            
        
        
            Active
            
        
            Viewed 407 times
        
    1 Answers
0
            
            
        First create your virtual env using this post and activate it!
Create the kernel using:
ipython kernel install --name=gen-py3
Now the kernel details would be in:
/usr/local/share/jupyter/kernels/gen-py3
note: you can cd to this folder and open the file kernel.json and see the details of your env, for example mine is:
 "argv": [
  "/usr/local/opt/python/bin/python3.7",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "gen-py3",
 "language": "python"
Which means is taken out of the global Python env b/c of this  "/usr/local/opt/python/bin/python3.7"
In some cases when you're running in your venv it's constantly taken out of you global env and not your venv. Not try to run in your venv:
virtualenv -p python3 venv
source <env_name>/bin/activate ; in our case venv
pip install ipython
pip install ipykernel
and make sure you run
ipython kernel install --name=venv-test
from your venv ipython. for example if your virtual env is venv and the location is
~/venv
run:
/Users/nathanielkohn/venv/bin/ipython kernel install --name=venv-test
Now open the kernel.json file, find the location by running:
jupyter kernelspec list
And your kernel.json file is with the venv:
{
 "argv": [
  "/Users/<your_user_name>/venv/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "venv-test",
 "language": "python",
 "metadata": {
  "debugger": true
 }
 
    
    
        Kohn1001
        
- 3,507
- 1
- 24
- 26