You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default method to install Google OR-Tools on Google Colab did not work for me. Although the installation said successful, I could not import the package on Google Colab.
NOTE: I am running the commands below directly on Google Colab.
# Install the package with pip.
!pipinstallortoolsLookinginindexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/CollectingortoolsDownloadingortools-9.4.1874-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0MB)
|████████████████████████████████|16.0MB4.6MB/sCollectingprotobuf>=3.19.4Downloadingprotobuf-4.21.6-cp37-abi3-manylinux2014_x86_64.whl (408kB)
|████████████████████████████████|408kB47.3MB/sRequirementalreadysatisfied: numpy>=1.13.3in/usr/local/lib/python3.7/dist-packages (fromortools) (1.21.6)
Requirementalreadysatisfied: absl-py>=0.13in/usr/local/lib/python3.7/dist-packages (fromortools) (1.2.0)
Installingcollectedpackages: protobuf, ortoolsERROR: pip'sdependencyresolverdoesnotcurrentlytakeintoaccountallthepackagesthatareinstalled. Thisbehaviouristhesourceofthefollowingdependencyconflicts.
tensorflow2.8.2+zzzcolab20220719082949requiresprotobuf<3.20,>=3.9.2, butyouhaveprotobuf4.21.6whichisincompatible.
tensorflow-metadata1.10.0requiresprotobuf<4,>=3.13, butyouhaveprotobuf4.21.6whichisincompatible.
google-cloud-bigquery-storage1.1.2requiresprotobuf<4.0.0dev, butyouhaveprotobuf4.21.6whichisincompatible.
google-api-core1.31.6requiresprotobuf<4.0.0dev,>=3.12.0; python_version>"3", butyouhaveprotobuf4.21.6whichisincompatible.
Successfullyinstalledortools-9.4.1874protobuf-4.21.6# Import the package.fromortools.linear_solverimportpywraplpfromortools.initimportpywrapinit---------------------------------------------------------------------------ModuleNotFoundErrorTraceback (mostrecentcalllast)
[<ipython-input-2-bdfd7560093b>](https://localhost:8080/#) in <module>1# Step 1. Import the required libraries.---->2fromortools.linear_solverimportpywraplp3fromortools.initimportpywrapinitModuleNotFoundError: Nomodulenamed'ortools'
Part 2. Successful method
I had to install the dependency, protobuf separately for a specific version that suits both packages installed on Google Colab as well as OR-Tools first and then install the OR-Tools package.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Part 1. Default method
Ref: https://developers.google.com/optimization/install
The default method to install Google OR-Tools on Google Colab did not work for me. Although the installation said successful, I could not import the package on Google Colab.
NOTE: I am running the commands below directly on Google Colab.
Part 2. Successful method
I had to install the dependency,
protobuf
separately for a specific version that suits both packages installed on Google Colab as well as OR-Tools first and then install the OR-Tools package.Beta Was this translation helpful? Give feedback.
All reactions