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'
Related
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 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`
I have an installation script for ERPNext that works just fine on Ubuntu 18.04.
When I run the same script on 20.04 I am obliged to wait more than 20 minutes for it to complete where it takes around 30 secs on 18.04.
My script includes these two lines:
./env/bin/pip install numpy==1.18.5
./env/bin/pip install pandas==0.24.2
Their output is:
Collecting numpy==1.18.5
Downloading numpy-1.18.5-cp38-cp38-manylinux1_x86_64.whl (20.6 MB)
|████████████████████████████████| 20.6 MB 138 kB/s
Installing collected packages: numpy
Successfully installed numpy-1.18.5
Collecting pandas==0.24.2
Downloading pandas-0.24.2.tar.gz (11.8 MB)
|████████████████████████████████| 11.8 MB 18.0 MB/s
Requirement already satisfied: python-dateutil>=2.5.0 in ./env/lib/python3.8/site-packages (from pandas==0.24.2) (2.8.1)
Requirement already satisfied: pytz>=2011k in ./env/lib/python3.8/site-packages (from pandas==0.24.2) (2019.3)
Requirement already satisfied: numpy>=1.12.0 in ./env/lib/python3.8/site-packages (from pandas==0.24.2) (1.18.5)
Requirement already satisfied: six>=1.5 in ./env/lib/python3.8/site-packages (from python-dateutil>=2.5.0->pandas==0.24.2) (1.13.0)
Building wheels for collected packages: pandas
Building wheel for pandas (setup.py) ... done
Created wheel for pandas: filename=pandas-0.24.2-cp38-cp38-linux_x86_64.whl size=43655329 sha256=0067caf3a351f263bec1f4aaa3e11c5857d0434db7f56bec7135f3c3f16c8c2b
Stored in directory: /home/erpdev/.cache/pip/wheels/3d/17/1e/85f3aefe44d39a0b4055971ba075fa082be49dcb831db4e4ae
Successfully built pandas
Installing collected packages: pandas
Successfully installed pandas-0.24.2
The line "Building wheel for pandas (setup.py) ... /" is where the 20 min delay occurs.
This is all run from within the Frappe/ERPnext command directory, which has an embedded copy of pip3, like this:
erpdev#erpserver:~$ cd ~/frappe-bench/
erpdev#erpserver:~/frappe-bench$ ./env/bin/pip --version
pip 20.1.1 from /home/erpdev/frappe-bench/env/lib/python3.8/site-packages/pip (python 3.8)
erpdev#erpserver:~/frappe-bench$
I would be most grateful for any suggestions how to speed it up.
I just update pip using pip install --upgrade pip and it solved.
Your issue may be less to do with your distribution and more to be with the Python version in your virtualenv. Ubuntu 20.04 has its default Python pointing to 3.8.
From the pandas project listing on PyPI, your pip searches for a version that's compatible with your system, as provided by the project maintainers.
It seems you're using CPython3.8. pandas==0.24.2 does not wheels built for your version, so your system builds them for itself each time. You can check the available download files from here.
Possible Solutions:
While creating your env, check out this answer to generate a virtual environment for a different version. Seems like your options are between 3.5, 3.6 and 3.7.
Build a wheel for CPython3.8 and ship it along with your script. You can install your package from using that.
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.