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)
Related
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")
I've installed Python 3.7, and since installed python 3.8.
I've added both their folders and script folders to PATH, and made sure 3.8 is first as I'd like that to be default.
I see that the Python scripts folder has pip, pip3 and pip3.8 and the python 3.7 folder has the same (but with pip3.7 of course), so in cmd typing pip or pip3 will default to version 3.8 as I have that first in PATH.
This is great, as I can explicitly decide which pip version to run. However I don't know how to do to the same for Python. ie. run Python3.7 from cmd.
And things like Jupyter Notebooks only see a "Python 3" kernel and don't have an option for both.
How can I configure the PATH variables so I can specify which version of python3 to run?
What OS are you running? If you are running linux and used the system package panager to install python 3.8 you should be able to invoke python 3.8 by typing python3.8. Having multiple binaries named python3 in your PATH is problematic, and having python3 in your PATH point to python 3.8 instead of the system version (which is likely a lower version for your OS) will break your system's package manager. It is advisable to keep python3 in your PATH pointing to whatever the system defaults to, and use python3.8 to invoke python 3.8.
The python version that Jupyter sees will be the version from which you installed it. If you want to be able to use Jupyter with multiple python versions, create a virtual environment with your desired python version and install Jupyter in that environment. Once you activate that specific virtual env you will be sure that the jupyter command that you invoke will activate the currect python runtime.
I recommend you use pyenv a great tool for manage multiple python versions on the same system. Once installed you need to create a virtualenv, then activate the virtualenviroment and there you can install any libraries you want in a safe way.
By the way also come with an automatic installer pyenv-installer
Regards
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 installed a specific version of python with pyenv. When typed pyenv version in terminal, i see 3.5.0 (set by /Users/lcherukuri/.python-version). But when I typed python3, I got python3 command not found. How to fix this? pip3 is Also not found
pyenv manages shim executables for commands like python3 and pip3. If pyenv's shims aren't available in your shell, it usually means one of two things:
pyenv isn't fully installed
or
pyenv shell features aren't active
As your pyenv command is working but the shims aren't, it most likely means the shell features aren't activated. As of writing, the correct way is to ensure the init command output is evaluated. On macOS, you can add the following to your ~/.bash_profile:
eval "$(pyenv init -)"
Older installation instructions might not include that step or just have you add pyenv's bin directory to the PATH, which is not enough. If you used pyenv-installer, this step is hinted at in a warning at the end of the installation process.
If you installed both python 2.x and python 3.x using pyenv, run the following to enable both versions to be found globally (python, python2 and python3 aliases).
Add the specific versions you are using:
pyenv global 3.8.3 2.7.18
pyenv is just a Python version manager. It may be able to see a Python 3.X installed even if python3 isn't installed in your $PATH.
You need to add python3 to your $PATH. You can see how to do that here.
By default, MacOS uses python3 to differentiate between the native pre-installed python (which is Python 2.7) and any post-installed Python 3.X distributions. The same goes for pip and pip3.
From the pyenv documentation on managing versions:
Locating the Python Installation
Once pyenv has determined which
version of Python your application has specified, it passes the
command along to the corresponding Python installation.
Each Python version is installed into its own directory under $(pyenv
root)/versions.
For example, you might have these versions installed:
$(pyenv root)/versions/2.7.8/
$(pyenv root)/versions/3.4.2/
$(pyenvroot)/versions/pypy-2.4.0/
As far as pyenv is concerned, version names
are simply the directories in $(pyenv root)/versions.
I had the python3 in path. I also executed pyenv global 2.x.x 3.x.x. But I still got the same error.
What eventually worked for me is executing this line in the project root (with whichever version replacing 3.X.X)
pyenv shell 3.X.X
Note: This sets the shell specific python version so it's not really a solution to the problem posted. Just a workaround to get python3 working.
Using Python I require both python 2.7 and python 3.5 for different packages. I am trying to install the following package NepidemiX. I get an error when I do this as I have a newer version of python installed.
To combat this I am trying to create a virtual environment. To do this I am using the virtualenv package.
I have created and activated this and am now faced with
(my_project)Your-Computer:your_project UserName$)
In my terminal.
How do I now proceed to install my package from here? Do I need to install python 2.7 in this environment first, or do I simply copy the desired package into the environment ... ?
Please could you instruct me how to correctly set this up?
Many thanks!
Virtual environment is only for libraries. It uses python versions installed on your computer. You can specify the version of python by using the -p attribute while creating the environment, for ex. virtualenv -p python3 env creates a python 3 enviroment (provided you have it installed in your computer and on the PATH). Check this answer.
After you activate the environment (source /env/bin/activate), just pip install libraries, and the environment takes care of installing the correct version.