This question already has answers here:
Using both Python 2.x and Python 3.x in IPython Notebook
(11 answers)
Closed 1 year ago.
I have python3 in my jupyter notebook but I want to make it for python2 as well. How can I install for both versions?
Jupyter will launch with the python version that is installed on the environment you're working in.
If you want to use multiple versions of python, you can use an environment management system like Conda to create different environments with different versions of python.
Miniconda is a light version of conda that you could use to get what you want.
First click to kernel tab, then a dropdown menu will show up. Click change kernel and select python 2. If python 2 didn't show up check out this:
How to change jupyter kernel from Python 2 to python 3?
You can make it reverse.
Related
I launched JupyterLab which is using a Python 3 kernel. However, when I am running the following commands below, it is showing different Python versions.
!python -V
Output: Python 2.7.18
from platform import python_version
print(python_version())
Output: '3.6.10'
I am expecting the Python 3.6.10 version to appear as it is the kernel that I launched/that is running. Is there a way to activate the Python 3 version whenever I run the "!python -V" command?
The original question is about python kernels so I quickly answer that.
Kernels are independent of python that you run you jupyter with.
Try this command:
jupyter kernelspec list
You will see your kernels. If you want to have another one here is the doc (https://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments)
not going deep into that as I can see this is probably not the actual problem.
It seems to me you want to change the interpretor called by "python" command.
You did not specify your OS. So in short:
In MacOs update the symbolic link (How to set Python's default version to 3.x on OS X?)
In Ubuntu use update alternatives (Unable to set default python version to python3 in ubuntu)
In Windows - hmm, haven't use windows in a while so probably here (https://superuser.com/questions/1576758/how-do-i-alias-python3-on-windows)
This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
I used
conda install python=3.9.4
on Anaconda Prompt to update my python version.
Then I tried opening a previous PyCharm project which ran on version 3.8.8. I want to use the updated version of python as my Python Interpreter. Does anyone know how to do that?
CTRL + ALT + S with that shortcut go to interpreter page and click select box.
There are show all end of the list. Click it and when the window pop up click '+' which is in the right side of window.
Then you should choose path of the new python. It's done!
This question already has answers here:
How to change default Python version?
(19 answers)
Closed 2 years ago.
I am trying to make Python version 3.9.1 my default python version. When I type “python —version” into terminal, it returns Python 2.7.16.
"whereis python3 returns "/usr/bin/python3". So, I change the alias with “alias python=/usr/local/bin/python3”. This temporarily sets my version to python3. In terminal, “python —version” returns "Python 3.9.1" and I can run Python 3.9.1 in the terminal by typing "python". Great.
However, this change is temporary. If I exit the shell and reenter, or open a new tab, I have to repeat the process. How do I make this permanent?
Also, will this cover everything on my OS that points to Python 2? For instance, will pip now point to Python3 and not 2? Thank you!
I will suggest to use pyenv (https://github.com/pyenv/pyenv) for managing differrent python versions on your machine. Other system programs which depends on py2 may break if you just relink python command to new version.
This question already has answers here:
Can existing virtualenv be upgraded gracefully?
(6 answers)
Closed 2 years ago.
Is it possible to set a specific interpreter (Python 3.7 or Python3.8) without using any IDE but only using command line commands?
I know that is possible using Pycharm, Anaconda or other else, but I would know the command.
Thanks and good day
If you use conda or mini conda, you can set up separate virtual environment with the benefit of selecting a different interpreter version and different packages. I suggest you familiarise yourself with conda and miniconda, and how to start an environment, run scripts etc from terminal with their guides. Resources below:
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
This question already has answers here:
Use Conda environment in pycharm
(10 answers)
Closed 4 years ago.
I have two versions of python (2.7 and 3.6) in my system. I have created a virtual environment for python 3.6 using conda commands. Now I have python36 venv in my system. I wanted to use this python version in my Pycharm or Jupyter notebook.
Please advice on how it can be done?
Go to:
Pycharm -> Preferences -> Search for project interpreter in Project -> Select the path of python in virtual_env created, or create a new one(by clicking on gear).