Skip to main content

How to create a Python virtual environment in Ubuntu?

Run the following commands:

> sudo apt update
> sudo apt install python3
> python3 -V
> sudo apt install python3-pip
> pip3 -V
> pip3 install virtualenv
> virtualenv env
> source env/bin/activate
(env) > python -V
Python 3.10.1
(env) > pip -V
pip 21.3.1 from /home/user/env/lib/python3.10/site-packages/pip (python 3.10)
(env) > deactivate

Other way of creating virtual environment:

> python3.10 -V
Python 3.10.1
> python3.10 -m venv venv1
> source venv1/bin/activate
(venv1) > python -V
Python 3.10.1
(venv1) >pip -V
pip 21.2.4 from /home/user/venv-1/lib/python3.10/site-packages/pip (python 3.10)
(venv1) > deactivate
>

> python -V
Python 3.8.10
> python -m venv venv2
> source venv2/bin/activate
(venv2) > python -V
Python 3.8.10
(venv2) > pip -V
pip 20.0.2 from /home/user/venv-2/lib/python3.8/site-packages/pip (python 3.8)
(venv2) > deactivate
>

Comments

Popular posts from this blog

GoLang - How to check if key exists in map?

package main import "fmt" var m map[string]string func main() { m = make(map[string]string) m["foo"] = "abc" if val, ok := m["foo"]; ok { fmt.Println("foo found -", val) } else { fmt.Println("foo not found") } if val, ok := m["bar"]; ok { fmt.Println("bar found -", val) } else { fmt.Println("bar not found") } } Output: foo found - abc bar not found

AWS - Error - An error occurred (ExpiredToken) when calling the DescribeStacks operation: The security token included in the request is expired

Error:   An error occurred (ExpiredToken) when calling the DescribeStacks operation: The security token included in the request is expired. Reason: It occurred when I ran a MAKE command with a profile having expired token (security credentials) Fix: Generate new security credentials (aws sts assume-role) and run the command again

How to delete commits in Git?

Suppose you have 3 commits with SHAs as follows: HEAD~0 --> Commit 3 ccccccc HEAD~1 --> Commit 2 bbbbbbb HEAD~2 --> Commit 1 aaaaaaa If you want to remove the last two commits (i.e., commits 2 and 3) and make Commit 1 as the latest commit, run the following commands: git reset --hard aaaaaaa git push origin HEAD --force Now, the commit history would be as follows: HEAD~0 --> Commit 1 aaaaaaa