Using latest Python version - python-3.x

I am setting up a new computer and the current latest version of Python is Python 3.4.6. I am trying to update it to version 3.7.0 (the latest version at the time of writing).
I tried pyenv install 3.7.0 and it successfully installed.
But when I type $ python3 --version at the command line it still says Python 3.4.6.
When I type $ which python3 the path it shows is /.pyenv/shims/python3.
Navigating to that path I find that there also exists /.pyenv/shims/python3.7.
How do I point the python command to the newest install?
I know there are a million questions asking how to point python from Python 2.x to Python 3.x. But I have not found one showing how to point from Python 3.old to Python 3.new
I am using Linux OpenSuse.

Use the pyenv global command. In this case, it should be pyenv global 3.7.0. Check out the pyenv commands list for more info.

Related

Can't downgrade python 3.9.6 to 3.7.12 on MacOS 12.2.1?

I am working on a single project and got my Mac with Python 3.9.6.
For all the relevant packages I need to use I need to use Python 3.7 to make them work (Stellargraph, Tensorflow... )
I have installed pyenv and installed python 3.7.12 and set it to global but when I am checking the version python3 --version I still get 3.9.6.
Please advise how can I safely downgrade Python to lower version.

Should i remove Python 3.6 while installing Python 3.8 or newer?

I tried to install a certain python module that required python 3.6 minimum to work properly so I checked my version using python --version which gave me the output of Python 2.7.17 and then used python3 --version giving me Python 3.6.9. Now, I know for a fact that i have Python 3.8 installed because I ran apt install python3.8 just before checking the version.
If someone wants to know what my system is running; I am currently running Elementary OS 5.1.7 Hera.
EDIT:
(IDK what term to use, I want to say I am done going through answers, and I liked none.)
After a while of whacking my brain, I decided not to uninstall the 3.6 version as It may have version specific modules which if removed may cause other installed programs to break.
Since I just use Linux for my college-work, It wont matter if more than one versions are installed anyway.
Sorry for any mistakes I may have made, I was never good at this kind of things.
Use conda to install and manage different versions of Python (or lots of other software, for that matter). Install different Python versions in separate conda environments. For example:
Find what python versions are available:
conda search python
Output (as of the time of writing, in the future I expect that the latest Python versions will be higher):
Loading channels: done
# Name Version Build Channel
python 1.0.1 0 conda-forge
python 1.2 0 conda-forge
...
python 3.9.0 h88f2d9e_1 pkgs/main
python 3.9.0 ha017127_4_cpython conda-forge
Install the Python versions you need in separate environments. Here, install Python 3.9.0 in environment named python39:
conda create --name python39 python=3.9.0
Switching environments is easy:
conda activate python39
# python is now 3.9.0
conda deactivate
# back to the default python
or (deprecated now):
source activate python39
source deactivate
SEE ALSO:
conda docs: Managing environments
This question is more appropriate for Unix & Linux.
Python installations (more generally, versioned installations of software) co-exist on linux using version numbers. You can likely run Python 3.8 using the python3.8 command (or else, locate where you installed it and run from there / add the location to the PATH environment variable to run directly).
Likewise, for each python version you can install its own package manager (e.g. install pip3.8 by python3.8 -m pip install pip) and use it to install packages for that python version. (As different projects require different sets of packages, the general practice is to create a "virtual environment", i.e. a separate copy of the needed version of python, pip and their package installation folders for each project, and install the required packages there - for more information see e.g. this excellent answer).
Regarding the command python3 (usually /usr/bin/python3) is just a symbolic link, you can replace it with the version you like (as long as it remains compatible with what the system expects - i.e. python3 of version no less than your built-in python3/python3-minimal, otherwise you will probably break something), e.g. assuming which python3 gives you /usr/bin/python3, you can
sudo rm /usr/bin/python3 #remove existing link
sudo ln /usr/bin/python3.8 /usr/bin/python3 # create a new link to the version of your choice
(although a better alternative could be instead aliasing it alias python3='/usr/bin/python3.8' and adding this to ~/.bashrc).
Whatever you do, do not uninstall python3-minimal as it is - at least, on Ubuntu - required by the system and uninstalling or changing it will likely break the system.

How can I move from the default pre-installed Python 2.7 on my Mac to accessing Python 3.7 from Anaconda in Terminal?

I may be leaving out many details, but I'll attempt to construct the best picture of what is happening here.
My Mac is running OS Catalina 10.15.6, I got it back in April, and it has Python 2.7 in
I'm learning to use pip install and PyPI from terminal, and the first oddity I noticed was that I had to install pip. I shouldn't have, because it comes with Anaconda Navigator. So I did sudo easy-install pip and it installed. Then I did pip install requests which worked fine, then pip install colorama and then it threw this error message:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: colorama in ./Library/Python/2.7/lib/python/site-packages (0.4.3)
My desire is to be able to use the Anaconda Python from terminal, since this 2.7 Python is dying and I need to be able to do so for my upcoming bootcamp and current Python course. I tried many conda commands to create an environment, see my current environment, etc, and they all failed because my terminal doesn't recognize conda as a command. I see this:
ryanlindsey#Ryans-MacBook-Pro ~ % conda info --envs
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda create -n myenv python=3.6
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda
zsh: command not found: conda
I've read stack overflow suggestions to add it to my path, but even when I use the code it seems to do nothing.
If this is useful, here is my PATH when I do echo $PATH
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
My shell I am using is zsh.
Anyone experienced in solving problems like this?
MacOS comes with python 2.7 installed by default. You can't move or remove it. Catalina also comes with python 3.7 (though it requires the download of Xcode command line tools when first run to complete it.)
Usually, python 3 versions are instigated with the command python3. Similarly, pip3 manages libraries for python 3, while pip manages libraries for python 2.
It doesn't look like you've actually installed Anaconda. Anaconda is a third-party product, which does not come bundled with the OS. You'll need to install that and follow the instructions on their website.
https://docs.anaconda.com/anaconda/install/

How do I change my python version to 3.5.2 in CentOS Linux?

My Linux box has python version 2.6.6 and I want to change/update the python version to 3.5.2 or later releases. The box has no internet connection, no pip working, no apt* working. Looking for help as I'm a noob in this area. All I have is a Python version 3.5.2 downloaded from internet and moved it to /usr/bin
Also Updated the ~/.bashrc file, but no changes happened, result is shown in screenshot.
Used this update command too but not worked alternatives --install /usr/bin/python python /usr/bin/python3.5.2 2
TIA!!
whereis python will show you the current situation, which is probably a symlink to the previous python version.
Just replace that symlink, so it points to /usr/bin/python3.5.2

Nosetests execution with different Python versions?

I'm having trouble with Python 2.7 & 3.5. Right now I use GIT to acquire repositories and their python folders all have 2.7 syntax.
The problem: When i'm attempting to Automate using repositories, my .local/bin nosetests first line of code shows:
#!/usr/bin/python3
so, it checks for
.local/lib/Python3.5/site-packages/nose
Nowhere to be found is a Python 2.7 folder with similar directories to Python 3.5.
So I will always get a syntax error, as its checking my repositories Python coding, and since they are not Python3 syntax, it will give me errors. I checked using command
python -v
python3 -V
and indeed have 2.7 and 3.5 installed.
So I just need guidance/help on how to just gain Python 2.7 site packages with nosetests, so I can automate correctly using the same version as the repositories python. If I left out anything, I will try my best to fill in the gaps/add more details. I will of course troubleshoot.
Nowhere to be found is a Python 2.7 folder with similar directories to Python 3.5.
First, uninstall nosetests for python 3 with pip3 uninstall nose.
Then install nosetests for 2.7 with pip2.7 install nose.
After you do this, the default nosetests should be for python 2.7.
You may want to look into the default python for your project to python2.7 by using virtualenv.

Resources