How to change Python version in Anaconda, install Numpy and sklearn 0.17? - python-3.x

I'm new to machine learning. I literally have no idea what I'm doing but I need tools to understand how machine learning works.
I just download Anaconda Python from here. I saw that the version I downloaded is 3.7 but I need a 3.5.
I don't really understand how to install Numpy 1.10 as well as sklearn 0.17
Can you please guide me how to install these?

The best way to do this is by using a custom conda environment. You can do this by either of the following:
install the full version of Anaconda (the current version with Python 3.7)
install Miniconda for a much smaller download
Then open Anaconda Prompt in the Windows start menu. Then do:
conda create -n customenvname python=3.5 numpy=1.10 scikit-learn=0.17
Follow the prompts.
To activate the new environment and get off and running, just do conda activate customenvname. You are now in a Python 3.5 environment with all the dependencies you need:
(base) C:\Users\user>conda activate customenvname
(customenvname) C:\Users\user>python --version
Python 3.5.6 :: Anaconda, Inc.
(customenvname) C:\Users\user>conda list
# packages in environment at C:\Users\user\Miniconda3\envs\customenvname:
#
# Name Version Build Channel
blas 1.0 mkl
certifi 2018.8.24 py35_1
mkl 11.3.3 1
numpy 1.10.4 py35_2
pip 10.0.1 py35_0
python 3.5.6 he025d50_0
scikit-learn 0.17.1 np110py35_1
scipy 0.17.1 np110py35_1
setuptools 40.2.0 py35_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_0
wheel 0.31.1 py35_0
wincertstore 0.2 py35hfebbdb8_0
NOTE: the mkl package is an optimization of some of the most used scientific computing libraries maintained by anaconda.

Related

Pandas build fail M1 Big Sur 11.1

I am using MacBook m1 which is running Big Sur 11.1 ,and I have installed Xcode-commandline-tools version 12.3 and it has installed python3.8.5 and pip3 .python3 and pip are native apps,that is they run in ARM
pip3 version 20.3.3
python3 version 3.8.5
setuptools version 51.0.0
wheel version 0.36.2
when I type python3 -m pip install pandas
The output is :
Defaulting to user installation because normal site-packages is not writeable
Collecting pandas
Downloading pandas-1.2.0.tar.gz (5.4 MB)
|████████████████████████████████| 5.4 MB 150 kB/s
Installing build dependencies ... error
And with a very long list of error about 30,000 lines (only last few lines)
and
pip3 list output is
cppy 1.1.0
kiwisolver 1.3.1
numpy 1.20.0rc1
pip 20.3.3
pyparsing 2.4.7
python-dateutil 2.8.1
setuptools 51.0.0
six 1.15.0
wheel 0.36.2
Is pandas not yet supported or I am doing it wrong and same goes with Matplotlib.
Install Miniforge for arm64 (Apple Silicon)latest installer here: installer here
Now create a conda environment for whatever version you have (I'm running 3.9.2)
conda create -n cenv python=3.9.2
conda activate cenv
conda install pandas
You will drive yourself nuts trying to get all the different packages working if you try to go from wheels/pip, at time of writing.
I think I got pandas working but couldn't get matplotlib working due to kiwi solver issues. Use miniforge/conda. This is the way.
You can try installing pandas version 0.25.3. This is the most stable release of Pandas which brings in numpy 1.19.1 which is the most stable version of NUMPY.
try running pip install pandas==0.25.3, and it should install the required packages.

Unable to install tensorflow using conda with python 3.8

Recently, I upgraded to Anaconda3 2020.07 which uses python 3.8. In past versions of anaconda, tensorflow was installed successfully. Tensorflow failed to be installed successfully in this version.
I ran the command below;
conda install tensorflow-gpu
The error message that I received is shown below;
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- tensorflow-gpu -> python[version='3.5.*|3.6.*|3.7.*|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0|>=2.7,<2.8.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
The following specifications were found to be incompatible with your CUDA driver:
- feature:/win-64::__cuda==11.0=0
Your installed CUDA driver is: 11.0
Is there a conda command with the right parameters to get tensorflow installed successfully?
UPDATE:
TF is now compatible with Python 3.8
Tensorflow is not compatible with Python 3.8. See https://www.tensorflow.org/install/pip
You need to downgrade your python version :
conda install python=3.7
Create an environment with python 3.7 and then activate it:
conda create -n p37env python=3.7
conda activate p37env
And install tensorflow.
This worked for me, and found out the answer from the Anaconda user guide (under how to use a different python version: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python )
From the requirement page:
Python 3.8 support requires TensorFlow 2.2 or later.
So there is a verison of Tensorflow compatible with python 3.8.
The problem is that TensorFlow 2.2.0 is not available through conda on Windows, this should be the reason why you get PackagesNotFoundError when running
conda install tensorflow=2.2
EDIT 15/03/21
Tensorflow 2.3.0 is compatible with Windows
i think we have two options here
pip install tensorflow
or we can use another env of anaconda such as like this below
conda create -n tf tensorflow pydotplus jupyter
conda activate tf
Actually you can directly use pip inside anaconda prompt, after I tested it, I found the conda is capable with pypi, first run the anaconda prompt with administrator permission (in windows), then enter "conda update --all" to make sure all the packages are latest, finally enter "pip install tensorflow" to install (the new version of tensorflow already includes tensorflow-gpu).
Then using VS code to open an ipynb and run
import tensorflow as tf
tf.test.gpu_device_name()
everything looks good.
For more info please refer to Anaconda official docs: https://docs.anaconda.com/anaconda/ .
Latest development for tensorflow installation on anaconda.
https://anaconda.org/anaconda/tensorflow
https://anaconda.org/anaconda/tensorflow-gpu
9 days ago, Anaconda uploaded a new tensorflow v2.3 package. Anaconda3 2020.07 (uses python v3.8) users can easily upgrade to tensorflow v2.3 with the following commands;
conda install -c anaconda tensorflow
conda install -c anaconda tensorflow-gpu
I have personally tested that the installation worked successfully.
The other answers for this question have now become obsolete.
Expanding upon William's answer here with more explicit instructions and caveats. Pip is the recommended way to install latest version of tensorflow as per tensorflow's installation instructions -- "While the TensorFlow provided pip package is recommended, a community-supported Anaconda package is available."
Here is the code that uses pip to do the installation in a Conda environment:
conda create -n env_name python=3.8
conda activate env_name
conda install pandas scikit-learn matplotlib notebook ##installing usual Data Science packages that does include numpy and scipy
pip install tensorflow
python -c "import tensorflow as tf;print(tf.__version__)" ##checks tf version
In general, we should be careful while mixing two package managers (conda and pip). So, it is suggested that:
Only after conda has been used to install as many packages as possible
should pip be used to install any remaining software. If modifications
are needed to the environment, it is best to create a new environment
rather than running conda after pip.
For an example, if we would like to install seaborn in the just created env_name environment, we should:
conda create --name cloned_env --clone env_name
conda activate cloned_env
conda install seaborn
Once we check the cloned_env environment is working fine, we can delete the env_name environment.
I was running into the same issue in conda prompt for Python 3.8.5 and fixed it using a Python wheel instead. Here are the steps:
Open conda prompt and install pip if you don't have it already: python -m pip install --upgrade pip
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp38-cp38-win_amd64.whl
Note: If you need a CPU specific tensorflow, use this wheel: https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp38-cp38-win_amd64.whl
I just downgraded python to 3.7 as tf is not avialable to 3.8 version also I cannot use virtualenv for code that's why
The only working answer for me is:
conda install -c conda-forge tensorflow
It appears that tensorflow 2.5 on GPU has issues with spyder. So, I made new environment and installed tensorflow gpu as suggested by anaconda. Now I have to use either prompt or jupyter . At least it works
For macos users I suggest create an environment with python 3.7 and install tensorflow there.
You can run these commands too:
conda create -n new_env_name python=3.7
conda activate new_env_name
I had a similar problem in Anaconda Spyder. Here was my solution (In the Anaconda Console):
conda install pip
pip install tensorflow ==2.2.0

Conda install of pytorch fails

I created an environment with conda and I want to install pytorch in it, but it doesn't work. After I get inside my environment with source activate env_name I tried this: conda install pytorch torchvision -c pytorch (I also tried it like this: conda install -c pytorch pytorch torchvision) but I am getting this error:
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: ......
Error: Could not find some dependencies for pytorch: mkl >=2018, cudatoolkit >=9.0,<9.1, blas * mkl, cudatoolkit >=10.0,<10.1, cudatoolkit >=9.2,<9.3, blas * openblas, cudnn 7.0.*, cudatoolkit 9.*
Did you mean one of these?
pytorch, pytorch-gpu, pytorch-cpu
Did you mean one of these?
cudatoolkit
You can search for this package on anaconda.org with
anaconda search -t conda cudatoolkit 9.*
(and similarly for the other packages)
Here are my installed packages:
backports 1.0 py34_0
backports.shutil-get-terminal-size 1.0.0 <pip>
decorator 4.0.11 py34_0
get_terminal_size 1.0.0 py34_0
ipython 4.2.0 py34_0
ipython-genutils 0.1.0 <pip>
ipython_genutils 0.1.0 py34_0
libgfortran 1.0 0
numpy 1.9.2 py34_0
openssl 1.0.2l 0
path.py 10.0 py34_0
pexpect 4.2.1 py34_0
pickleshare 0.7.4 py34_0
pip 9.0.1 py34_1
ptyprocess 0.5.1 py34_0
python 3.4.5 0
readline 6.2 2
scipy 0.16.0 np19py34_0
setuptools 27.2.0 py34_0
simplegeneric 0.8.1 py34_1
six 1.10.0 py34_0
sqlite 3.13.0 0
tk 8.5.18 0
traitlets 4.3.1 py34_0
wheel 0.29.0 py34_0
xz 5.2.3 0
zlib 1.2.11 0
What should I do? Thank you!
Pytorch's vision package (aka torchvision) was developed post-Python 3.4, and so only has versions supporting Python 2.7, 3.5-7. Please create a new environment with a later Python version. Note it is always better to include the packages you care about in the creation of the environment, e.g.,
conda create -n env_name -c pytorch torchvision
and Conda will figure the rest out. If you need to have a specific version of Python, you can include that as well (e.g., python=3.6).
Please try the following steps.It worked fine for me.
source activate env_name
conda install -c pytorch pytorch
open python shell
import torch
I can't give you a definite answer cause you didn't provided the info about the Python version, platform you're using.
Go to the official website for Pytorch, choose a installation method according to your platform, Python version and whether you need CUDA.

have 3.x and 3.y anaconda version on offline mode

I posted this question few days ago about switching between 2 versions of Anaconda.
what I'm looking for now is to understand why I got an erreur where I tried to create python 3.5 environment on off line mode:
#conda create -n py35 python=3.5 anaconda --offline Fetching package
metadata ... Solving package specifications: . PackageNotFoundError: Package not found: '' Package missing in current linux-64 channels:
- python 3.5*
You can search for packages on anaconda.org with
anaconda search -t conda python
should I install an additional version of Anaconda which contents python 3.5 or the present version Anaconda has all subversion of python 3 (i.e 3.6 3.5 3.4 ....) ?
No, Python 3.5 is a package like numpy, pandas, etc. You need to download the package an install it. You should not install a separate version of Anaconda to get a new version of Python.
You can create an empty environment by leaving off any package specifications, then install whatever you want into the environment.
conda create -n py35 --offline
conda install --offline -n py35 python-3.5.tar.bz2

Changing Default Python env.(from 2.7 to 3.3) in Anaconda on Mac OS 10.8

I have the Anaconda distribution installed for Mac. I have Mac OSX 10.8 (Mountain lion). The problem I don't often use Anaconda is because the default Python which it uses is 2.7 while I work on 3.3 or atleast prefer to work on that.
I really like the Spyder IDE of Anaconda. Is there a way I can get the default environment on Anaconda changed to 3.3 instead of 2.7 so that Spyder and iPython all use 3.3 default?
I see the following help from Anaconda site:
$ conda create -n py3k python=3 anaconda
Here python=3 and anaconda are package specifications, and it is the job of the SAT solver inside conda to find a consistent set of packages which satisfies these requirements. As the root environment uses Python 2, we had to specify the major version explicitly.
After adding the binary directory of the newly created environment to the PATH environment variable, which may be done using
$ source activate py3k
My question is I have separately installed Python 3.3 and associated Scientific Python packages like Pandas, numpy, scipy, scikit-learn etc using Homebrew so that it doesn't conflict with my Mac OS default Python 2.7. So now if I run the above Conda commands in Mac Terminal will it interfere with other Python packages I have installed using Homebrew? or will it automatically install/upgrade the python and other packages in the Anaconda library without interfering with either the Homebrew installed Python or Mac OS default Python?
Please advise.
No, the Homebrew and Anaconda Pythons will stay completely independent of one another. Just make sure you don't have PYTHONPATH set, which causes this to not be true.
Also, you should know that Spyder is not available for Python 3 in Anaconda yet, because PySide has not yet been built for Python 3.
I had installed Anaconda with python 2.7, but even after adding python3:
conda create --name Py3 python=3
spyder continued to call python2.7
creating an environment with BOTH spyder and python=3 worked for me:
conda create --name SpyPy3 python=3 spyder

Resources