- 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
>>>
- 現代C++編程:從入門到實踐
- Python量化投資指南:基礎、數據與實戰
- 小創客玩轉圖形化編程
- NumPy Essentials
- Building a Quadcopter with Arduino
- 小程序開發原理與實戰
- Unity 5 for Android Essentials
- 用戶體驗增長:數字化·智能化·綠色化
- 區塊鏈項目開發指南
- Python預測分析與機器學習
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- Building Microservices with Go
- INSTANT Lift Web Applications How-to
- C#程序設計基礎與實踐
- Mastering VMware vSphere Storage