- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 171字
- 2021-07-02 14:00:18
Importing modules through the Python interpreter
If you are importing any module, then the Python interpreter checks if that module is available or not. You can do this by using the import statement. If that module is available, then you will see the >>> prefix after pressing the Enter key. This indicates that the execution was successful. If that module doesn't exist, the Python interpreter will show an error:
>>> import time
>>>
After importing the time module, we get the >>> prefix. This means that the module exists and this command gets executed successfully:
>>> import matplotlib
If the module doesn't exist, then you will get Traceback error:
File "<stdin>", line 1, in <module>
ImportError: No module named 'matplotlib'
So here, matplotlib isn't available, so it gives an error: ImportError: No module named 'matplotlib'.
To solve this error, we will have to install matplotlib and then again try to import matplotlib. After installing matplotlib, you should be able to import the module, as follows:
>>> import matplotlib
>>>
- Getting Started with Gulp(Second Edition)
- Learning Docker
- Practical Data Science Cookbook(Second Edition)
- OpenNI Cookbook
- Internet of Things with the Arduino Yún
- JS全書:JavaScript Web前端開發指南
- R語言與網絡輿情處理
- ElasticSearch Cookbook(Second Edition)
- INSTANT Adobe Edge Inspect Starter
- R Data Science Essentials
- Oracle實用教程
- Oracle Data Guard 11gR2 Administration Beginner's Guide
- Python 3快速入門與實戰
- 你好!Java
- Java EE 7 Development with WildFly