Created
March 8, 2020 08:47
-
-
Save smetronic/18ac8bda0dcf2b94567450f7d0170315 to your computer and use it in GitHub Desktop.
List of python libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List of Libraries availabe below | |
OpenCV for python 2 and 3 | |
Fswebcam | |
MQTT | |
DHT11 Sensor | |
PyautoGUI | |
Tkinter | |
Xlib | |
espeak | |
Festival | |
PyQt4 | |
Xrdp | |
midori | |
Apache web server | |
Matplotlib | |
Gspread | |
To install PIP: | |
PIP for python2 - sudo apt-get install python-pip | |
PIP for python3 - sudo apt-get install python3-pip | |
To Update packages: | |
The below commands are for updating every applications or package which already installed. | |
sudo apt-get update | |
sudo apt-get upgrade | |
To install python3: | |
Python2 is available with Raspbian OS. | |
To install python3 in Raspberry Pi | |
sudo apt-get install python3 | |
To install OpenCV in Raspberry Pi for python2 in single command: | |
sudo apt-get install libopencv-dev python-opencv | |
To install OpenCV in Raspberry Pi for python3 in single command: | |
sudo apt install libqtgui4 | |
sudo apt install libqt4-test | |
sudo pip3 install opencv-python | |
To use Camera in Raspberry Pi: | |
fswebcam is needed to handle camera related applications | |
sudo apt-get install fswebcam | |
To use MQTT Protocol in Raspberry Pi: | |
Message Queuing telemetry Transport library to use mqtt protocol based applications | |
sudo pip install paho-mqtt | |
To interface DHT11 Sensor with Raspberry Pi | |
sudo apt-get install git-core | |
git clone https://github.com/adafruit/Adafruit_Python_DHT.git | |
cd Adafruit_Python_DHT | |
sudo apt-get install build-essential python-dev | |
sudo python setup.py install | |
Pyautogui: | |
Pyautogui Library is for mouse and keyboard related function without accessing physically, we can able to access through python code using pyautogui library. Visit pyautogui cheat sheet for more mouse and keyboard related functions. | |
Pyautogui for python 2 - sudo pip2 install pyautogui | |
Pyautogui for python 3 - sudo pip3 install pyautogui | |
Tkinter: | |
For GUI based application, ex: creating a graphical view like virtual keyboard using push-buttons, text box etc. | |
sudo apt-get install python3-tk | |
if it ask for Xlib library enter the below command | |
Xlib: | |
sudo pip3 install Xlib | |
Voice output in Raspberry Pi: | |
There are two voice output that we can use in Raspberry Pi | |
espeak voice output: | |
sudo apt-get install espeak | |
Festival voice output: | |
sudo apt-get install festival | |
Python code to use espeak and festival | |
import espeak | |
import festival | |
import subprocess | |
data="Hai Pantech" | |
subprocess.call(["espeak",data]) #for espeak | |
subprocess.call('echo '+data+'|festival --tts', shell=True) | |
pyQT4: | |
It is also GUI based designing for Raspberry Pi | |
pyQt4 for python2 - sudo apt-get install python-qt4 | |
pyQt4for python3 - sudo apt-get install python3-qt4 | |
if it shows import error in qwt5, then enter below command | |
sudo aptitudeinstall python-qwt5-qt4 | |
To use Raspberry Pi on Laptop using Remote desktop in Windows: | |
sudo apt-get install xrdp | |
After Installing xrdp, we have to enable SSH. For that Click Raspberry Pi logo presented in top left corner, then choose preferences, select Rpi configurations, then enable SSH which presented in Interfaces tab by clicking at radio button and then click OK to reboot the system.In short term(Rpi logo-Preferences-Rpi configurations-Interfaces(tab)-enable SSH) | |
After rebooted, connect the Raspberry Pi to the network, as a result you will get local IP address of the Raspberry Pi when you place the cursor on wi-fi icon as shown in the figure below. | |
Local IP in wi-fi icon | |
Now open Remote desktop icon in Raspberry Pi, then enter the IP address of the Raspberry Pi, here for example : 192.168.1.17 as shown below | |
Remote desktop in windows | |
Now click Connect, It will ask for confirmation, Click Yes. Then It will prompt for username and password, Enter the username and password (Default username: pi) and password: raspberry. click OK to open the Raspberry pi virtually in windows. | |
To Preview Camera: | |
sudo apt-get install luvcview | |
After installing luvcview, open Terminal and type luvcview. Highly used to adjust the camera focus | |
To configure Serial communication in Raspberry Pi: | |
Normally Serial communication is enabled to use GPS/GSM/RFID like serial based hardware interfaces and also serially actuated applications . First type the below commands in terminal | |
sudo nano /boot/cmdline.txt | |
After the above command executed, It opens the window as shown below. Delete the whole commands and replace with below commands | |
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwaitdtoverlay=pi3-disable-bt | |
Press ctrl+X , then press Y to choose Yes, and click Enter to return to Terminal. Then type below command in Terminal | |
sudo nano /boot/config.txt | |
Add below commands to the current window | |
dtoverlay=pi3-disable-bt | |
enable_uart=1 | |
Press ctrl+X, then press Y to choose Yes, and Click Enter to return to Terminal, then type below command to reboot the Raspberry Pi | |
sudo reboot | |
After reboot, Serial will be enabled which is identified by Bluetooth is disabled. Generally either Serial or Bluetooth can be enabled at a time. | |
To open browser in Raspberry Pi from python code: | |
sudo apt-get install midori | |
Python code to open midori | |
import subprocess | |
choice="http://192.168.1.17/GPIO.php" | |
subprocess.Popen(["midori","-a",choice]) | |
Change the URL, to open in browser in the choice variable. for example: choice=”http://www.pantechsolutions.net” | |
Webpage using Raspberry Pi: | |
Type the below commands in order to install webpage application with PHP | |
sudo apt-get install apache2 | |
sudo apt-get install php libapache2-mod-php | |
sudo apt-get install git-core | |
git clone git://git.drogon.net/wiringPi | |
cd wiringPi | |
./build | |
Now open terminal and enter the below command to create php application file in root folder to control appliances or to display sensor values through webpage | |
cd /var/www/html | |
Below enter name in the form of php extension as shown | |
sudo leafpad gpio.php | |
It will open leafpad to enter the PHP code. Type your PHP code in that leafpad and close it after saving it. | |
To open, this PHP page through your Webpage . Note down the local IP address as shown above. then open browser in PC/Mobile and connect the device with same network which raspberry pi is connected. then in browser URL tab, Type below URL in webpage. Below here IP and PHP file name may vary | |
192.168.2.26/gpio.php | |
To use Google smart sheet in Raspberry pi : | |
Gspread: | |
Gspread library is used for accessing google smart sheet from Raspberry pi python to update sensor values, which can be further used for machine learning process from the cloud | |
sudo pip install gspread | |
oauth2client: | |
oauthclient library is used to access the cloud resources which having oauth client such as Google API | |
sudo pip install --upgrade oauth2client | |
PyOpenSSL: | |
sudo pip install PyOpenSSL | |
To install Matplotlib for plotting 2D graphs in Raspberry Pi using python script: | |
sudo pip install matplotlib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment