I am using anaconda and python 3.8. Now some of my codes need to be run with python 2. so I create a separate python 2.7 environment in conda like below:
after that, I installed spyder, then launcher spyder amd spyder is showing I am still using python 3.8
how do i do to use python 2.7 in spyder with a new environment?
Thanks
conda create -n py27 python=2.7 ipykernel
conda activate py27
pip install spyder
According to the documentation here, this should create a python2.7 virtual environment (29 April 2021) with spyder installed. I verified that spyder version 3.3.6 is python2.7 compatible
conda create -y -n py27 python=2.7 spyder=3.3.6
However, I could not run spyder in the py27 environment due to conflicts that conda failed to catch. The workaround shown by asanganuwan on this Spyder Github Issue page worked for me also
Found a workaround to use Spyder on python 2.7.
setup two virtual environments for Python 2.7 and 3.6.
Launce anaconda navigator and install spyder 3.3.6 on both the environments
Launch spyder on the environment with Python 3.6
Preferences-->Python Interpreter --> set the Python path for 2.7
Restart Spyder
Done!
So my recommendation is next run
conda create -y -n py36 python=3.6 spyder=3.3.6
conda activate py36
spyder
And follow the last three instructions from asanganuwan.
Also you should use the conda package manager as much as possible since it is smarter with managing requirements. When I try to use pip install spyder after activating the environment, it warns of version conflicts and fails to start.
I suggest to first search for an anaconda 2.7 version you want, then install it explicitly, this will make resolving much faster, give you a "stable" anaconda and allow you more control while installing all anaconda packages:
First:
conda search anaconda
Then select a version that has 27, in my case:
# Name Version Build Channel
anaconda custom py27_0 pkgs/main
anaconda custom py27_1 pkgs/main
anaconda custom py27h689e5c3_0 pkgs/main
anaconda custom py35_1 pkgs/main
............
anaconda 5.3.1 py27_0 pkgs/main
anaconda 5.3.1 py37_0 pkgs/main
............
anaconda 2019.10 py27_0 pkgs/main
............
I went with:
conda create -n py2 Python=2.7 anaconda==5.3.1 -y
You can manage environments from Ananconda's Navigator. https://docs.anaconda.com/anaconda/navigator/getting-started/#navigator-managing-environments
I guess you are on previous pip;
Use which pip command to find out your current pip environment.
Modify your .bash file and set another new environment variable for your new pip.
Source your .bash file.
Try to install spyder by using new pip env variable; something like pipX install spyder
Related
I'm trying to install python 3.7 env for miniconda on my raspberry pi 4 model B.
But when I'm doing conda install python 3.7
I get Error: No packages found in current Linux-armv7l channels matching: 3.7.
how can I install python 3.7 in some way on that miniconda?
You can try to create new environment with this python version:
conda create -n your_env_name python=3.7
And then you need to activate it:
activate your_env_name
Here you will find more about conda environments.
miniconda only have under python3.4 for armv7l
so you need to use python3.7 for armv7l(no anaconda or miniconda just python)
You might want to try with this command : conda install -c anaconda python=3.7
Tell us if this works
I'm relatively new to Jupyter Notebook and have been struggling with python versions with Jupyter Notebook.
I installed seaborn but import error occurred saying no seaborn package found. It shows on upper right corner of Jupyter "Python 3" but it returned Python 2.7 when I run !python --version. Also when I run print(sys.path), the result is below.
['', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mysql-0.0.1-py3.5.egg', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/extensions', '/Users/Cynthia/.ipython']
My guess is that my python kernel isn't pointing correctly to python3 although notebook shows it's python3. Could someone pls help me solve this? It would be helpful if there could be code to run in Jupyter cell. Thank you!
When you run python --version, It won't spit python 3.5.x, because python refers to python2 unless you aliased python as python3. So it makes sense that you see python 2.7.x when you run python --version.
As for py2 when you run conda env list, they are env names you set. They are just names, not python versions.
What needs to be done I think is to find out where your jupyterlab is installed, which I think in (base) environment. In your base environment, run conda list, where you will see a list like this:
(base) ➜ test conda list
# packages in environment at /Users/gwanghyeongim/.pyenv/versions/miniconda3-latest:
#
# Name Version Build Channel
brotlipy 0.7.0 py38haf1e3a3_1000
ca-certificates 2020.6.24 0
certifi 2020.6.20 py38_0
cffi 1.14.1 py38hed5b41f_0
chardet 3.0.4 py38_1003
conda 4.8.4 py38_0
conda-package-handling 1.6.1 py38h1de35cc_0
cryptography 2.9.2 py38ha12b0ac_0
idna 2.10 py_0
libcxx 10.0.0 1
libedit 3.1.20191231 h1de35cc_1
libffi 3.3 hb1e8313_2
ncurses 6.2 h0a44026_1
openssl 1.1.1g h1de35cc_0
pip 20.2.2 py38_0
pycosat 0.6.3 py38h1de35cc_1
pycparser 2.20 py_2
pyopenssl 19.1.0 py_1
pysocks 1.7.1 py38_1
python 3.8.3 h26836e1_1
python.app 2 py38_10
readline 8.0 h1de35cc_0
requests 2.24.0 py_0
#and so on...
See if you see jupyterlab in the list. If so, your jupyter notebook is in (base) environment.
Now the most likely scenario is you installed seaborn in py2 environment. That means you dind't install seaborn in your base environment. Install it by running conda install seaborn or pip install seaborn.
If something didn't work so far, try runnning conda upgrade --all -y to upgrade packages. It might be from collision between deprecated packages.
P.S
My suggestion is you create a separate environment and run packages on it.
Run conda create -n your_env_name to do so(replace your_env_name to the name you want set)
Activate by running conda activate the_env_you_just_created
If 2 doesn't work somehow, make sure you run conda init your_shell, where your_shell can be found by running echo $SHELL, where the last word after / is your shell.
Make sure you see (your_env_name) at the first part of command prompt. If so, your env is activated. Now install packages on here and do your project, rather than on base environment.
Since you mentioned you use conda you can do something like the following. From your terminal:
conda create -n sb python=3
conda activate sb
conda config --env --add channels conda-forge
conda install -y pandas matplotlib numpy scipy seaborn jupyterlab # some default packages
jupyter lab
Whenever you want to use this conda environment again you have to do
conda activate sb
before you can run jupyter lab.
Note, if you didn't changed the default, you should see your terminal prompt changing when activating an environment, i.e. the name of the environment comes before your prompt. In our case here (sb) <prompt>.
To solve the issue with your current conda environment, more information is needed.
I install anaconda with python version 3.7 on Windows.
Then I want to install TensorFlow, but it don't support python 3.7.
I try to install python 3.5, but get this error:
How to resolve this conflict to install python 3.5?
You can create an environment with the Python version of your choice.
Example create an environment called deep with python 3.5 and tensorflow:
conda create -n deep python=3.5 tensorflow
After that we can activate it with
conda activate deep
While in this environment you will have Python 3.5 and tensorflow. You can add other packages to your environment anywhere. E.g. adding latest scipy, pandas, and jupyter
conda install --name deep scipy pandas jupyter
Updated: While in the environment, you don’t have to specify the environment name, when installing packages. You can do:
conda install package_name
When done doing awesomeness, you can deactivate as so:
conda deactivate
;)
So your workflow when working with Tensorflow, would include activating your ‘deep’ environment and use Python 3.5 there ;) e.g.
conda activate deep
jupyter lab
Assuming you have installed tensorflow and jupyter, this will start a service on your default browser where you can start building your project.
Happy coding ...
Check out conda documentation https://conda.io/docs/user-guide/tasks/manage-pkgs.html
Today Tensorflow doesn't support Python 3.7 . You have to create a new environment with Python 3.4, 3.5 or 3.6. With conda it's easy to handle different environments and versions. In addition it's recommended using pip to install Tensorflow.
Python 3.6 with CPU:
conda create -y -n name_of_env python=3.6 # create new environment
source activate name_of_env # activate the new environment
pip install tensorflow # install tensorflow
Python 3.6 with GPU (please check the additional setup for using a GPU):
conda create -y -n name_of_env python=3.6
source activate name_of_env
pip install tensorflow-gpu
Tip: Finally you can test your installation with the following command:
echo 'import tensorflow as tf; print(tf.__version__)' | python
# 1.12.0
So I have an old version of conda install
conda -V
conda 4.5.4
the current version of anaconda is 5.1 and it is running python 3.6.4
I wanted to test my code base on the newer version of conda so I tought I could install a new env first with conda and it would give me the latest version of the conda distribution
conda create -n py364 python=3.6 anaconda
I thought this would be installing the latest anaconda with python 3.6.4 but it is actually installing python 3.6.1
is it possible to install the new anaconda version in a env?
It can depends on your environement.
Test: conda search python to see the available versions for your environement.
Have you tried: conda create -n py364 python=3.6.4 anaconda ?
as #darthbith suggested in the comments
you should always update your conda version using
conda update conda
then if you call
conda create -n py364 python=3.6 anaconda
it will install the latest distribution of anaconda on the with python 3.6.
or you could also call
conda create -n conda51 anaconda=5.1
to install the actual distribution you are targeting
Anaconda 2.3.0 with python 3.4.0 is installed on my Windows PC.
I want to upgrade to python 3.5.
I already created an Anaconda environment using conda create --name py35 python=3.5 and activated it using activate py35.
After installing python 3.5 and conda 6.0.1, still default version is 3.4.2
even in cmd after activating py35, when I write python --version it says:
python 3.4.2 :: Anaconda 2.3.0 (64-bit)
please help
The command conda create --name py35 python=3.5 creates a new environment which has no effect, by design, on your default environment. To upgrade the default version do
conda install python=3.5
(out of interest, why not go to the latest python release, 3.6? In that case you can just do conda update python)