********************** Internet communication ********************** Download all scripts: :download:`internet_communication.zip ` Set up a virtual environment ============================ https://docs.python.org/3/tutorial/venv.html .. code-block:: bash # Create a new virtual environment $ python3 -m venv venv-COURSE # Activate the virtual environment # macOS or Unix $ source venv-COURSE/bin/activate .. code-block:: powershell # Windows $ venv-COURSE\Scripts\activate.bat open_weather_w_urllib.py ======================== .. literalinclude:: internet_communication/open_weather_w_urllib.py :language: python3 open_weather_w_urllib3.py ========================= Since the ``urrlib3`` and ``certifi`` libraries are not part of the standard library they have to be installed manually e.g. from the `Python Package Index (PyPI) `__ using the ``pip`` command. .. code-block:: bash pip install urllib3 pip install certifi .. literalinclude:: internet_communication/open_weather_w_urllib3.py :language: python3 open_weather_w_requests.py ========================== Since the ``requests`` library is not part of the standard library it has to be installed manually e.g. from the `Python Package Index (PyPI) `__ using the ``pip`` command. .. code-block:: bash pip install requests .. literalinclude:: internet_communication/open_weather_w_requests.py :language: python3