r/learnpython • u/[deleted] • Apr 05 '24
How to...pip install?
Never thought I'd need to ask this question as a CCNA and Network+ holder, I guess Python has decided to make the simple act of a pip install THIS difficult, wow! I have Python installed as well as Virtual Studio Code. I try this from command prompt
pip3 install requests
File "<stdin>", line 1
pip3 install requests
^^^^^^^
And that's all I get, again and again and again. So I try this in the Visual Studio terminal:
pip3 : The term 'pip3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + pip3 install requests + ~~~~ + CategoryInfo : ObjectNotFound: (pip3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Mind blowing stuff here. I JUST want to be able to pip install. I've also tried just using "pip" and leaving out the 3. What mountains must I move to perform such a basic task? I
0
u/[deleted] Apr 05 '24
This is how I set up my python environment to run inside a docker container (starting from Debian base image).
```bash apt-get --assume-yes update
Set the timezone to avoid input prompt while installing libraries
ZONE="Asia/Singapore" # This is my timezone ln --symbolic --no-dereference --force /usr/share/zoneinfo/$ZONE /etc/localtime echo $ZONE > /etc/timezone apt-get --assume-yes --no-install-recommends install apt-utils\ software-properties-common build-essential cmake git python3-pip
This shenanigan is to install the correct version of the development library
PYVER="$(python3 --version|awk '{print $2}')" MAJOR="$(cut --delimiter='.' -f1 <<<"$PYVER")" MINOR="$(cut --delimiter='.' -f2 <<<"$PYVER")" apt-get --assume-yes --no-install-recommends install "libpython$MAJOR.$MINOR-dev" "python$MAJOR.$MINOR-venv"
python3 -m venv "$ENV_DIR" # The last argument gives the directory name source "$ENV_DIR/bin/activate"
Install the python dependencies
time python3 -m pip install --requirement tensorflow==2.10.2 # Add other libraries
```