A solution to the problem that the Python version in Conda cannot be changed

problem

Create an environment with Anaconda with python version 3.8.5. スクリーンショット 2020-12-17 9.19.13.png

However, when I run conda, the python version is 2.7.16.

(base) renato@MacBook-Pro ~ % conda activate renatoenv
(renatoenv) renato@MacBook-Pro ~ % python --version
Python 2.7.16

What you did

① Reinstall Anaconda ② Install pyenv

Since it did not change even if I did ①, I will omit it as an article. I will explain ②.

What is pyenv

It's a tool that makes it easy to switch between python versions. It is convenient for switching between 2 series and 3 series.

Install pyenv

First, let's install pyenv. If you bring it from git, you can use the above command, and if you can use brew, you can use the command below.

$ git clone git://github.com/yyuu/pyenv.git ~/.pyenv
$ brew install pyenv

Edit bash_profile Then edit bash_profile to get it through the path of pyenv.

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

Finally apply the save of bash_profile

$ source ~/.bash_profile

Then the Python version changed.

(base) renato@MacBook-Pro ~ % conda activate renatoenv
(renatoenv) renato@MacBook-Pro ~ % python --version
Python 3.8.5

References

This article was written with reference to the following information.

-Installing and using pyenv, what to do if you can't switch python versions

Recommended Posts

A solution to the problem that the Python version in Conda cannot be changed
Solution to the problem that you can't activate by putting conda in pyenv
[Python] Solution to the problem that elements are linked when copying a list
Solution to the problem that Ctrl + z cannot be used in Powershell in Docker for windows environment (provisional)
A solution to the problem that files containing [and] are not listed in glob.glob ()
[Python] A program that calculates the number of socks to be paired
Address to the bug that node.surface cannot be obtained with python3 + mecab
Try to calculate a statistical problem in Python
The problem that the ifconfig command cannot be used
Even if the development language is changed to python3 in Cloud9, version 2 is displayed in python --version
I want to create a priority queue that can be updated in Python (2.7)
Let's look at a differential equation that cannot be solved normally in Python
Causes when python version cannot be changed using pyenv
Run the output code with tkinter, saying "A, pretending to be B" in python
Workaround for the problem that UTF-8 Japanese mail cannot be sent with Flask-Mail (Python3)
[Jinja2] Solution to the problem that variables added in the for statement are not inherited
A story that got stuck when trying to upgrade the Python version on GCE
A mechanism to call a Ruby method from Python that can be done in 200 lines
How to find the first element that matches your criteria in a Python list
Finding a solution to the N-Queen problem with a genetic algorithm (2)
How to use the __call__ method in a Python class
Change the standard output destination to a file in Python
Processing of python3 that seems to be usable in paiza
Solution when the image cannot be displayed with tkinter [python]
How to get the last (last) value in a list in Python
Finding a solution to the N-Queen problem with a genetic algorithm (1)
How to set up a simple SMTP server that can be tested locally in Python
A program that automatically resizes the iOS app icon to the required image size in Python
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
How to solve the problem that video content cannot be played on Firefox for Linux
What seems to be a template of the standard input part of the competition pro in python3
How to pass the execution result of a shell command in a list in Python (non-blocking version)
[Python] A program to find the number of apples and oranges that can be harvested
ABC166 in Python A ~ C problem
In the python command python points to python3.8
How to get the Python version
The story that the version of python 3.7.7 was not adapted to Heroku
How to determine the existence of a selenium element in Python
[Python] Solving the import problem due to the difference in entry points
[Python] It seems that global variables cannot be referenced in Multiprocessing
A story that struggled to handle the Python package of PocketSphinx
The 15th offline real-time how to write reference problem in Python
How to check the memory size of a variable in Python
A record that GAMEBOY could not be done in Python. (PYBOY)
How to judge that the cross key is input in Python3
A timer (ticker) that can be used in the field (can be used anywhere)
[Introduction to Python] How to use the in operator in a for statement?
How to check the memory size of a dictionary in Python
A function that measures the processing time of a method in python
I wanted to solve the ABC164 A ~ D problem with Python
A script that returns 0, 1 attached to the first Python prime number
Jupyter Notebook 6.0.2 cannot be installed in the Python 2.7 environment created in Anaconda
The 14th offline real-time how to write reference problem in python
Change the active version in Pyenv from anaconda to plain Python
Solve the subset sum problem with a full search in Python
[python] A note that started to understand the behavior of matplotlib.pyplot
[Python] A program that rotates the contents of the list to the left
The 18th offline real-time how to write reference problem in Python
"A book to train programming skills to fight in the world" Python code Solution example --1.6 String compression
Run the output code on the local web server as "A, pretending to be B" in python
"A book to train programming skills to fight in the world" Python code solution example --1.5 One-shot conversion