I would like to upgrade my python version in my r-reticulate environment. First I activate the right environment like this:
conda activate /Users/quinten/Library/r-miniconda/envs/r-reticulate
Let's check the python version:
python3 --version
Python 3.7.11
So I installed the newest python version for macOS which is 3.11.1. After that, I tried to change the Python version like described here (How to change Python version of existing conda virtual environment?) using this:
conda install python=3.11
This was successfully installed, but when I check again the version python3 --version it still returns 3.7.11. So I was wondering if anyone knows how to change the python version in an r-reticulate environment? I would like to use this in ‘Quarto’.
One shouldn't need a system-level Python - it really only complicates working with Conda environments. Rather than changing an environment's Python, it is more straightforward to create the environment with the desired specifications at the outset. For example, something like
library(reticulate)
conda_create("myenv", python_version="3.11")
Related
I was creating a virtual environment in python 3.7.9 but vscode is creating an environment in python 3.9.12 (I have anaconda installed with that version). I used the command ctrl+shift+p to change the environment to 3.7.9 but it's created in 3.9.12. I had to uninstall anaconda to create an environment. How to fix this?
Steps to change the Python version in VS Code:
change to your project path (e.g. using cd)
create a new virtual environment (venv) using your Python binary in the given version (e.g. python3.7):
`which python3.7` -m venv .venv
change your VS Code interpreter by clicking in the status-bar (see red rectangle below)
There is a corresponding relationship between Python version and CONDA version.
A simple modification of interpreter cannot change the python version. You must install the CONDA environment of the corresponding version of Python.
Here is the download page of conda
My python version in mac is 3.8 but I need 3.7 so I create environment python 3.7, and install the nest with conda. But when I import nest, there is still the error:ModuleNotFoundError: No module named 'nest'.
I checked the python3.7/site-packages, there is the nest:
It sounds like you're running the wrong Python binary (native version instead of 3.7). If you want to use a specific Python version, you could add it's install location to your $PATH before the system version.
You could use a tool like pyenv to help you manage your selected Python version (see this article).
When using an IDE (xcode, pycharm, etc.), it may not be aware of your conda environment and use the system python (which doesn't know about the conda installed NEST). You could check the corresponding runtime environment settings in the IDE to correctly reflect your py37 conda environment.
However, when you run python --version in your environment on the shell, it should correctly give 3.7 and the "which python" should point to your conda installed Python version in the py37 environment. If this is the case then python -c "import nest" should work.
(this answer could also help with the setup)
My base environment's Python version is the 3.7, the way I like it. However, I need to create a new environment that uses Python version 3.5.
I created my environment specifying version 3.5:
conda create --name dbconnect python=3.5
However, when I activate my environment (conda activate dbconnect) and check for the python version (python --version), I get
(dbconnect) computer-name:src vivian$ python --version
Python 3.7.3
I tried downgrading the Python version in the dbconnect environment by running conda install python=3.5 and get this
(dbconnect) computer-name:src vivian$ conda install python=3.5
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
It appears to have worked but it hasn't because when I check the Python version, it is still 3.7.3
(dbconnect) computer-name:src vivian$ python --version
Python 3.7.3
The only way to have my dbconnect environment have Python version 3.5 is to downgrade the Python version in my base environment, but I do not want to do that. How do I have my dbconnect environment use Python 3.5 and my base environment use Python 3.7?
Sharing the answer as per the comment by the original poster:
"I figured it out. My environment variables were getting messed up because my .bash_profile was bad".
I am trying to get into deep learning. I installed Anaconda to use jupyter and generally not to care about installing all of those packages like matplotlib etc myself. But I cannot install tensorflow as it works only with Python 3.4, 3.5, or 3.6 but I have 3.7. After I read about it I installed python 3.6.8. I uninstalled Anaconda and installed it again, nothing changed. After that, I used this command
conda install python=3.6.8
to presumably install python 3.6.8 for it (I found this solution somewhere on the web). The command worked but didn't change anything. Please help
A better (recommended) alternative is to create a virtual environment of the desired Python version and then use that environment to run Tensorflow and other scripts.
To do that, you can follow the instructions given here.
BUT, if you don't want to create a separate environment, then conda install python=<version> should do.
OR (not recommended) you can download the "latest" Anaconda installer with your required Python version bundled.
Source
Sometime command is not working as expected I was also facing same issue when I
used this command.
conda install python=<version>
then I have changed the Python version with the help of anaconda Navigator. I have create new enviornment and follow below instruction=>
In Navigator, click the Environments tab, then click the Create button. The Create new environment dialog box appears.
In the Environment name field, type a descriptive name for your environment.
3.In the Packages list select “Python” and in the Python version list select the version you want to use.
4.Click the Create button.
5.Navigator creates the new environment and activates it, as shown by the highlighted green bar. All actions take place in the active environment.
for more details please go through this link =>
https://docs.anaconda.com/anaconda/navigator/tutorials/use-multiple-python-versions/
By default, the conda environment will use the python version 3.7, since you installed Anaconda with python3.7.
You would need to create a symbolic link to the new version of the python (in your case python3.6.8) using
ln -s ~/anaconda3/bin/<python3.6.8>
(you may need to replace 'python3.6.8' with the appropriate file name).
Another, better way would be to create a new environment in conda and then use python3.6.8 as you would like. Follow steps at https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands to create an environment.
For python3.6.8, run the following command:
conda create -n <myenv> python=3.6.8
(replace 'myenv' with the name of your new environment)
After that, activate the environment with :
conda activate <myenv>
This is a bug of the macOS 10.14.6. I degrade the python version from 3.7.4 to 3.7.0 in Anaconda and it works. Here I share my solution. I solve this question in other website. Check the answer by clicking here(https://www.udemy.com/course/the-python-mega-course/learn/lecture/4775342#questions/11049798).
You just can change the python version by creating a new environment in anaconda.
It will ask for the python version when you create an environment
The most pain-free approach that worked for me was to install the legacy version of Anaconda. If you want Python 3.6 as default, I recommand downloading Anaconda 5.2.0 which was the last version to use Python 3.6 in base environment as default. (Legacy versions can be found here.)
If you also want the latest version of Anaconda, there is an easy way. With Anaconda 5.2.0 installed, you can actually update to newer versions of Anaconda by
conda update anaconda
which will try to update all your packages except keepping Python at 3.6.x.
I created an environment in Anaconda Navigator and indicated python version as 3.6.4. After the env has completed, I installed matplotlib, numpy and so on, but when I was running Jupyter Notebook on a browser, it's shown the python version - Python 2, like the screenshot shown:
Then, I checked what I installed in this environment in Anaconda Navigator, it's really shown that python version is 2. So I was trying to upgrade python version to 3.6.4, then it's prompted that as shown below, complaining: functools32 and python 3.6.4 can not be satisfied and in conflict.
Then I searched google what is functools32, the result is a dependency of matplotlib
I'm looking forward to get an answer from you. Thanks In Advance.
Updated: April 1st
As the screenshot shown, it hinted to me that Python will downgrade from 3.x to 2.x when I was trying to install PIL.
If you think you created an environment with Python 3.6.4 but the environment actually has Python 2.x then either you made a mistake while creating the environment, or you aren't actually using the environment you created, or one of the packages you installed after creating the environment forced a downgrade from 3.6.4 to 2.x (and I'm not sure if that's even possible).
If you open an Anaconda prompt and type
conda create -n new-env-name python=3.6.4 matplotlib
(where new-env-name is the name you want for your environment) then conda will show you what packages and what versions it is going to install in order to satisfy the dependencies of matplotlib. When I try this it lists Python 3.6.4 (as I asked) and matplotlib 2.2.2, but doesn't mention functools32.
I would try creating your environment from the command prompt as above, and then make sure this environment is actually the active one before using it.