Giter VIP home page Giter VIP logo

Comments (7)

minrk avatar minrk commented on May 27, 2024

Can you show the contents of /home/user/.local/share/jupyter/kernels/python2/kernel.json?

from ipykernel.

 avatar commented on May 27, 2024

Sure.

{
 "display_name": "Python 2", 
 "language": "python", 
 "argv": [
  "python", 
  "-m", 
  "ipykernel", 
  "-f", 
  "{connection_file}"
 ]
}

from ipykernel.

 avatar commented on May 27, 2024

Looks like this is causing issues here. What would be a solution in this case? I want to use libraries installed in the active conda environment but also keep both Python 2 and 3 available.

Thanks

from ipykernel.

minrk avatar minrk commented on May 27, 2024

Yes, so python in kernelspec will always refer to the Python of the notebook server's environment. This is why IPython (following Python's own rewrite of the #! line of scripts) hardcodes the full path to sys.executable at install time. By manually changing this, as was recommended in jupyter/notebook#397 is explicitly requesting the behavior you are seeing. If you want it to launch with a specific Python, you must specify the absolute path. If you want it to launch with Python 3 or legacy Python, but be sensitive to the env, then you can use python2 or python3.

from ipykernel.

 avatar commented on May 27, 2024

Thanks. Then what do you recommend for new users? Create an environment for Python 2 and another for Python 3, install ipykernel in both, and point the path in kernel.json to the appropriate location inside the environment?

By the way, using python2 might not work because it uses /usr/bin/python and can't find ipykernel.

from ipykernel.

minrk avatar minrk commented on May 27, 2024

I wouldn't suggest that new users modify any kernel.json. I would recommend that they run python2 -m ipykernel install and python3 -m ipykernel install one time, and be done. They can do this in envs if they wish, or not. If they choose to create new envs and want to install kernels for those envs, run python -m ipykernel --display-name 'Python <env>' in the env. This can be done on env creating with virtualenvwrapper, if it's a common enough action.

from ipykernel.

 avatar commented on May 27, 2024

Got it. python -m ipykernel --display-name 'Python <env>' looks really useful. Thanks.

from ipykernel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.