I am a beginner in machine learning. I am using colab as the primary development platform.
I would like to use the latest version of sklearn in my coding projects. However, colab's sklearn version is 0.22.
Can I update the scikit learn version in colab?
Thank you.
You mentioned that you have a 0.22 version, hopefully, you checked and received the following results (by default) in your colab notebook.
!pip list | grep scikit-learn
scikit-learn 0.22.2.post1
I presume that you already tried with the following command, which ideally installs the latest version of sckit-learn.
!pip install scikit-learn
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.7/dist-packages (0.22.2.post1)
Requirement already satisfied: numpy>=1.11.0 in /usr/local/lib/python3.7/dist-packages (from scikit-learn) (1.19.5)
Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn) (1.0.1)
Requirement already satisfied: scipy>=0.17.0 in /usr/local/lib/python3.7/dist-packages (from scikit-learn) (1.4.1)
As per the latest scikit-learn document, 0.24.2 is the latest version, which you can install/upgrade by overriding the version number as shown in the following script. It should help you if you want to upgrade to 0.24.2.
!pip install scikit-learn==0.24.2
Then, verify the scikit-learn version by following script.
!pip list | grep scikit-learn
scikit-learn 0.24.2
Also, alternative way to upgrade the package in a colab environment.
!pip install scikit-learn --upgrade
Ideally, you'll need to install it each time, however, some workaround such as you can save the current configuration into your google drive. Refer to the following script which was suggested in another post.
from google.colab import drive
drive.mount('/content/gdrive')
pip freeze --local > /content/gdrive/My\ Drive/colab_installed.txt
Refer to the following script to restore the environment from the file.
from google.colab import drive
drive.mount('/content/gdrive')
pip install --upgrade --force-reinstall `cat /content/gdrive/My\ Drive/colab_installed.txt`
Related
I have successfully downloaded a version of Python 3.10 to Colab, and Colab says I have the most up to date version of pandas. However, whenever I import pandas, the version is 1.3.5, while I need it to be up to date.
I tried restarting the kernel, but this did not fix things. The code and its output are below, excepting the long list I get when I download the newest version of Python.
!wget https://github.com/korakot/kora/releases/download/v0.10/py310.sh
!bash ./py310.sh -b -f -p /usr/local
!python -m ipykernel install --name "py310" --user
!python --version
Python 3.10.6
!pip3 install pandas --upgrade --no-deps
Requirement already satisfied: pandas in /usr/local/lib/python3.10/site-packages (1.5.2)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
import pandas as pd
print(pd.__version__)
1.3.5
Thank you so much for your time.
i have installed 3.10 version of python and now facing problem to inastall tensorflow C:\Python\python310>pip install tensorflow ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
Tf-nightly Python3.10 wheels supports Linux and MacOS. You can get them via pip install tf-nightly on the corresponding operating system.
Take a look at this #comment
I want to check if some packages are installed in the Colab. What is specific folder for storing the installed packages (e.g., keras)?
You can use the pip tool to list installed Python packages and their locations on the system:
!pip list -v | grep [Kk]eras
# Keras 2.2.5 /usr/local/lib/python3.6/dist-packages pip
# Keras-Applications 1.0.8 /usr/local/lib/python3.6/dist-packages pip
# Keras-Preprocessing 1.1.0 /usr/local/lib/python3.6/dist-packages pip
# keras-vis 0.4.1 /usr/local/lib/python3.6/dist-packages pip
Note that in Colab and other Jupyter notebook frontends, the ! character is used to execute a shell command.
If you are not able to find the package, you might have probably downloaded the package instead of installing it.
Incorrect command:
!pip download transformers
Correct command:
!pip install transformers
Next, in order to find the package run the following command:
!pip show transformers
C:\WINDOWS\system32>pip install tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
I installed the Python (3.6 64-bit), and wanna install tensorflow in Anaconda3.
And I upgraded pip to the latest version, 19.0.1.
Requirement already up-to-date: pip in c:\anaconda3\lib\site-packages (19.0.1)
So, how can I solve this problem?
if you have anaconda do conda install tensorflow. anaconda version of tensorflow is faster than pip anyways.
I am trying to use the bleeding edge version of sklearn installing it from their github as shown on line 2 in the below image. Line 5 imports some functions from this version of sklearn. This line works in my local and not on Google Colab. Am I missing something to hint the tool to use the latest installed version and not its cached version?
I am not sure why that's happening but if you uninstall scikit-learn before installing the latest dev, it would work:
[1] !pip uninstall scikit-learn -y
Uninstalling scikit-learn-0.19.1:
Successfully uninstalled scikit-learn-0.19.1
[2]!pip install Cython
!pip install git+git://github.com/scikit-learn/scikit-learn.git
Requirement already satisfied: Cython in /usr/local/lib/python3.6/dist-packages (0.28.2)
Collecting git+git://github.com/scikit-learn/scikit-learn.git
Cloning git://github.com/scikit-learn/scikit-learn.git to /tmp/pip-req-build-d59ukisw
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (1.14.3)
Requirement already satisfied: scipy>=0.13.3 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (0.19.1)
Building wheels for collected packages: scikit-learn
Running setup.py bdist_wheel for scikit-learn ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-is88dk15/wheels/a1/50/0e/316ef2ff8d4cfade292bd20b49efda94727688a153382745a6
Successfully built scikit-learn
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.dev0
[3] !pip freeze | grep scikit
scikit-image==0.13.1
scikit-learn==0.20.dev0
[4] from sklearn.preprocessing import CategoricalEncoder
[5] import sklearn
sklearn.__version__
'0.20.dev0'