Updated March 14, 2023
Introduction to Keras Install
Keras is the library used for neural networks in machine learning and artificial intelligence. Before learning the installation process of keras, we will try to understand the prerequisites that are necessary for the installation process. In this article, we will try to study keras install requirements and Keras Installation steps.
Keras Install Requirements
There are certain prerequisites that should be fulfilled after which we can proceed with the installation of Keras. First thing is that you should have any kind of operating system platform which can be either Windows, Mac, or Linux platform. Secondly, there should be python installed on your system which is of version 3.5 or higher.
As Keras is the library of python based that is used for neural network creation and manipulation. Hence, it is compulsory to have python installed on our system. We can open the terminal or command prompt for typing in the python instructions only when python is properly installed on our device. For checking whether python is installed on our system or not, we can simply type in python on the terminal. If it will be installed then we can see the output similar to as shown in the below image –
The latest version when this article is being written is 3.10.1 for python. In case, if you want to install python on your system due to its unavailability, then you can navigate to this official site for downloading the python with the latest version as of that time and as per your operating system which can be proceeded with the installation process.
Keras Installation Steps
Let us now proceed with the installation of Keras. the process is quite easy if you will follow each of the steps in a sequence that is mentioned below for proper installation of Keras on your system.
Step 1 – Virtual environment Creation
For managing various packages of python for various several projects we will need to create a virtual environment. This will make sure that none of the packages is being broken that are installed in other environments. Hence, it is always suggested to make use of the newly created virtual environment when you are going to create applications using python.
For windows operating system, we can make use of the following command on the terminal. After execution, a new virtual environment will be created –
py -m venv keras
Whose output is –
On Mac or Linux OS, we need to create the virtual environment with any name. Here we are creating with the name of educbaKerasEnv. Further, we can navigate to that folder using the below command –
python3 -m venv educbaKerasEnv
Which gives the following output after execution –
Step 2
Environment activation –
We will do the necessary pip executables and configurations of python in the path of our shell.
For Mac or Linux operating system, we will simply have to navigate to that particular folder that we have created for our virtual environment which can be done by using the following command –
cd educbaKerasEnv educbaKerasEnv $ source bin/activate
Which gives the following output after execution –
On windows, we will have to move into the folder named educbaKerasEnv by using below-mentioned command –
.\env\Scripts\activate
That gives the following output after execution –
Step 3 – Installation of necessary python libraries –
For smooth working of keras on your system, it is important to make sure that the following libraries are properly installed on your system as keras is dependent on them –
• Seaborn
• Pandas
• Matplotlib
• Numpy
• Scipy
• Scikit-learn
If you don’t have these libraries installed on your system then you can make use of the below commands one by one for installation of these libraries –
Numpy Library installation –
Pip install numpy
Output of the execution of the command will be –
Pandas Library installation –
Pip install pandas
Output of the execution of the command will be –
Matplotlib Library installation –
Pip install matplotlib
Output of the execution of the command will be –
Scipy Library installation –
Pip install scipy
Output of the execution of the command will be –
Seaborn Library installation –
Seaborn library allows us for visualizing our data in a very easy manner and acts as an amazing library. Command for installation is –
Pip install seaborn
Output of the execution of the command will be –
Scikit-learn library installation –
Scikit-learn is a machine learning library that is completely open-source. This library can be used to perform clustering, regression and classification algorithms. There are certain prerequisites for the installation of this library which are as mentioned below –
• Joblib 0.11 or higher version should be installed on your system.
• SciPy 0.17.0 or higher version should be installed on your system.
• NumPy 1.11.0 or higher version should be installed on your system.
• Python 3.5 or higher version should be installed on your system.
All the above libraries should be installed on your system and thereafter you can make use of the below command to install the scikit-learn library –
Pip install -U scikit-learn
The execution of the above command will give the following output –
Step 4 – Keras installation
Now, it’s time to go for the installation of keras using python as we have completed the installation of prerequisites. You can execute the below command for it –
Pip install keras
The execution of above command on terminal or command prompt gives the following output –
Step 5 – Exiting the virtual environment
After you are done with the installation of the libraries and working on your project of keras, you can exit the virtual environment by simply firing the command of deactivation as follows –
Deactivate
The execution of above command on terminal or command prompt gives the following output –
We can even go for the installation of anaconda cloud on your system and further create the conda environment where you can activate it and go for installation of spyder and the necessary libraries of python and lastly perform the anaconda keras installation. The last step would be to launch your spyder on the terminal of conda. After this, you can check if everything is installed or not by simply importing all these modules inside your project, and if the error occurs that module is not found that means that module is not installed properly.
Recommended Articles
This is a guide to Keras Install. Here we discuss the Introduction, requirements, steps, examples with code implementation. You may also have a look at the following articles to learn more –