Python - Installation
Install Python in Windows and set up the environment:
- Go to the official Python website (https://www.python.org/downloads/) and download the latest version of Python for Windows.
- Run the downloaded installer file and select "Install now" to install Python using the default settings.
- Add Python to your system PATH variable. To do this, follow these steps:
- Open the Windows Start menu and search for "environment variables".
- Click on "Edit the system environment variables".
- Click on the "Environment Variables" button.
- In the "System Variables" section, scroll down and find "Path".
- Click "Edit" and then "New".
- Add the path to the Python executable file, usually located in "C:\PythonXX", where "XX" is the version number you installed. For example, if you installed Python 3.10, the path would be "C:\Python310".
- Click "OK" on all the windows to close them.
- Open a new command prompt window and type "python" to verify that Python is installed and running correctly.
That's it! With these steps, you should be able to install Python and set up the environment on your Windows machine.
Install Python in Linux and and set up the environment:
- Open the terminal and update the package list using the following command: sudo apt-get update
- Install Python by running the following command: sudo apt-get install python3
- This will install Python 3. If you want to install Python 2, you can use the following command instead: sudo apt-get install python
- Verify the installation by checking the version of Python installed: python3 --version or python --version
- Depending on the version of Python you installed.
- To set up the environment for Python, you can create a virtual environment using the venv module. Here are the steps to create a virtual environment: python3 -m venv myenv
- This will create a new virtual environment in the directory myenv.
- Activate the virtual environment using the following command: source myenv/bin/activate
- Once you activate the virtual environment, you will see the name of the virtual environment in the terminal prompt.