Quick step to initial Python project
Apr 25, 2024
Install Python3
Python3 can be installed in various ways such as
- Official installer https://www.python.org/downloads/
- Package manager like Homebrew for macOS, apt-get for Linux-based.
Create Python Virtual Environment
mkdir my-python-app
python3 -m venv my-python-app
Activate virtual environment
source my-python-app/bin/activate
At this point the Terminal prompt will be changed to something like:
(my-python-app) $
We can perform any python3 or pip3 command from here.
For example: install boto3 dependency
(my-python-app) $ pip3 install boto3
Hello Python World
Create new Python source file named main.py
(my-python-app) $ vim main.py
def main():
print("Hello World")
if __name__ == "__main__":
main()
Run
(my-python-app) $ python3 main.py
Deactivate virtual environment
(my-python-app) $ deactivate
Happy coding !