Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install pip modules on google compute engine?

I am trying to run some python script using ssh to log into the google compute engine but all the installed pip modules are not found as I do not have permission to the .cache/pip folder in my user is there a correct way to do this?

like image 255
Anshul Sinha Avatar asked Jul 19 '17 11:07

Anshul Sinha


3 Answers

You should be running this with the root user. Also, if you need pip inside your GCP Instance, you can use the following commands:

sudo curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py

[Source]

like image 97
amitam Avatar answered Nov 16 '22 10:11

amitam


Use:

sudo apt-get install python3-pip

sudo runs this command as an administrator

apt-get is the standard package manager used on Debian Linux distributions

python3-pip is the package name for pip3

Once installed, you can install PIP modules with:

pip3 install MODULE_NAME

for example:

pip3 install tensorflow
like image 34
Josh Avatar answered Nov 16 '22 09:11

Josh


I'm not entirely sure there is one correct way to do this, but an easy way would be to use the conda python package manager. The lighter version of it is miniconda. You can get a minimal python installation with pip preinstalled, and virtual environments capability if you need. Assuming you are running on linux and want python 3, you'll have to run

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh

and then install conda with

bash Miniconda3-latest-Linux-x86_64.sh

At the end of this process you should have a minimal python installation (that includes pip) and you'll be able to install packages with pip as you are used to.

like image 33
teoguso Avatar answered Nov 16 '22 09:11

teoguso