Setting Up the Development Environment

To program for reinforcement learning, you’ll need to install several programs. In data analysis, installing Anaconda provides most of the required programs by default, making it convenient. However, here we’ll go through the process of setting up the development environment step-by-step, starting with installing Python.
 
Downloading the Python Installer
There are various Python versions available, but this book uses Python 3.7.7. Installing a different version could lead to errors when running examples, so it’s recommended to install this specific version. Download the executable file that matches your operating system: for a 64-bit OS, download the Windows x86-64 executable installer, and for a 32-bit OS, download the Windows x86 executable installer. Since most PCs today use 64-bit Windows 10, downloading the x86-64 file should work. However, it’s wise to check your Windows version using “My PC” before proceeding.
 
Changing the Installation Directory
Double-click the downloaded installer to start installing Python. While most steps can be followed as prompted, it’s advisable to change the installation location. Create a “Python377” directory under the C drive, then click the Browse button on the installation screen to specify the location.
 
Registering Environment Variables
After installing Python, set up the environment to run Python. Start by typing “My PC” in the Windows search bar to find the program. Once “My PC” appears in the search results, right-click it and select Properties to access system properties. Then, choose “Advanced System Settings” and click the “Environment Variables” button at the bottom. In the Environment Variables window, select the “Path” entry and click Edit. Click “New” and add two folder paths: “C:\python377” and “C:\python377\scripts.”
 
WindowsApps Environment Variable Location
In the environment variable editing screen, if the WindowsApps-related environment variable is above the Python environment variable, Windows will search WindowsApps before Python. Ensure that the Python environment variable is placed above WindowsApps.
 
Verifying the Python Installation
To verify that Python has been installed correctly, open Command Prompt by typing “cmd” in the Windows search bar. Run the command “python --version,” and it should display “Python 3.7.7.” If it doesn’t and instead opens a Windows application search window, go back to the environment variable setup steps and carefully review the installation.
 python -m pip install --upgrade pip
Upgrading pip
Python includes pip, a package manager that simplifies handling packages. Before using pip, upgrade it to the latest version by running the command “python -m pip install --upgrade pip.”
 pip install notebook
Installing Jupyter Notebook
To develop Python programs, you need an editor. While Python’s default editor, IDLE, is installed, other popular editors include PyCharm and Spyder. However, in AI, Jupyter Notebook is the most commonly used tool. Install it by running the command “pip install notebook.”
 jupyter notebook
Running Jupyter Notebook
To launch Jupyter Notebook, enter “jupyter notebook” in Command Prompt. Note that you cannot access directories higher than the one from which you start Jupyter Notebook. For example, if you start in the “C:\User\user” directory, you won’t be able to open programs in “C:\User\test” in Jupyter. To open a program, move to the desired directory or at least a parent directory before running Jupyter Notebook.
 pip install tensorflow
Installing TensorFlow 2.0
Google’s deep learning package, TensorFlow, can be easily installed using pip. Run “pip install tensorflow” to install the latest version. You can specify a version, such as 2.2, by adding “==version.”
 pip uninstall numpy
pip install numpy==1.19.3
Installing NumPy 1.19.3
Python 3.7.7 includes NumPy version 1.19.4 by default, which can sometimes cause errors with TensorFlow. Downgrade to version 1.19.3 by first uninstalling the current version with “pip uninstall numpy,” then installing the lower version with “pip install numpy==1.19.3.”
 
Running TensorFlow 2.2 Errors
When running TensorFlow 2.2, you might encounter an error related to msvcp140_1.dll not being installed. Download and install the necessary program from the Microsoft support site: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022.
 
Downloading the Microsoft Visual C++ Redistributable Package
Download the Microsoft Visual C++ Redistributable Package for Visual Studio 2015, 2017, and 2019. For a 32-bit Windows system, download the vc_redist.x86.exe program, and for a 64-bit system, download vc_redist.x64.exe.
 pip install matplotlib
Installing matplotlib
To visualize training results or fine-tune parameters, use a graphing package. While Python has various options, matplotlib is the most straightforward and intuitive. Install it to create graphs easily.
 pip install gym==0.2
Installing OpenAI Gym
OpenAI, a site providing resources for reinforcement learning, offers test programs packaged as OpenAI Gym. Simply installing the gym package gives access to various reinforcement learning programs.
 pip uninstall protobuf
Uninstalling protobuf
 pip install protobuf==3.20
Installing protobuf
In recent package installations, it is common to encounter compatibility issues with the protobuf version. As a result, it may be necessary to install a lower version to ensure proper functionality and avoid conflicts.

Post a Comment

Previous Post Next Post