ModuleNotFoundError: No module named ‘MySQLdb’

When running migration for a Django application with “python manage.py migrate”, I got the following error message ModuleNotFoundError: No module named ‘MySQLdb’ To fix install pip install mysqlclient This will require MySQL development package. On the Ubuntu server running MariaDB, I installed packaged libmariadb-dev sudo apt install libmariadb-dev Back to Errors

How to install Python 3.10 on CentOS 7

First, install the dependency yum install -y wget zlib-devel yum groupinstall -y “Development tools” Install OpenSSL as the openssl-devel package provided by CentOS is old version. Install OpenSSL from source with cd /usr/local/src wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz tar xvf openssl-1.1.1g.tar.gz cd openssl-1.1.1g ./config –prefix=/usr/serverok/openssl –openssldir=/usr/serverok/openssl no-ssl2 make make install Run following commands export PATH=/usr/serverok/openssl/bin:$PATH export LD_LIBRARY_PATH=/usr/serverok/openssl/lib export … Read more

ModuleNotFoundError: No module named ‘PIL’

When running a python application, I got the error message ModuleNotFoundError: No module named ‘PIL’ (venv) boby@sok-01:~/work/powder (master)$ python main.py Traceback (most recent call last): File “main.py”, line 6, in from extras import * File “/home/boby/work/powder/extras.py”, line 2, in from PIL import Image, ImageDraw, ImageFont ModuleNotFoundError: No module named ‘PIL’ (venv) boby@sok-01:~/work/powder (master)$ To fix … Read more

OSError: mysql_config not found

When installing the python mysqlclient module with pip, I got the error “OSError: mysql_config not found”. (venv) root@sok:~# pip install mysqlclient Collecting mysqlclient Downloading mysqlclient-2.1.0.tar.gz (87 kB) |████████████████████████████████| 87 kB 1.2 MB/s ERROR: Command errored out with exit status 1: command: /root/venv/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘”‘”‘/tmp/pip-install-r5qp0a97/mysqlclient/setup.py’”‘”‘; __file__=’”‘”‘/tmp/pip-install-r5qp0a97/mysqlclient/setup.py’”‘”‘;f=getattr(tokenize, ‘”‘”‘open’”‘”‘, open)(__file__);code=f.read().replace(‘”‘”‘\r\n’”‘”‘, ‘”‘”‘\n’”‘”‘);f.close();exec(compile(code, __file__, … Read more

Uvicorn

Uvicorn is a lightning-fast ASGI server used to serve Python ASGI frameworks like FastAPI, Django Channels, Quart, BlackSheep, etc… https://www.uvicorn.org To install Uvicorn, run To run, you can use See Python

Flask Python framework

Flask is a Python framework. You can find more info at the official website. https://flask.palletsprojects.com/ How to start a Flask application? To start flask application, run python app.py How to run flask application on port 80 To run flask application on port 80, use command flask run –host 0.0.0.0 –port 80 Or edit app.py, use … Read more

Install Python 3.8 on CentOS 6 from source

To install Python 3.8 on CentOS, you need to install OpenSSL as the one installed by CentOS from yum is very old. cd /usr/local/src wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz tar xvf openssl-1.1.1g.tar.gz cd openssl-1.1.1g ./config –prefix=/usr/serverok/openssl –openssldir=/usr/serverok/openssl no-ssl2 make make install Now edit file vi ~/.bash_profile at end of the file, add export PATH=/usr/serverok/openssl/bin:$PATH export LD_LIBRARY_PATH=/usr/serverok/openssl/lib export LC_ALL=”en_US.UTF-8″ … Read more

Python mechanize HTTP Error 403 request disallowed by robots.txt

When running following python script i get error “HTTP Error 403 request disallowed by robots.txt” from mechanize import Browser a = [‘https://google.com’, ‘https://serverok.in’, ‘https://msn.com’] br = Browser() for x in range(len(a)): br.open(a[x]) print(“Website title: “) print(br.title()) print(“\n”) To fix this, find br = Browser() Add below br.set_handle_robots(False) br.addheaders = [(‘User-agent’, ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 … Read more

error: Python.h: No such file or directory

When install dlib python module, i get error ERROR: Failed building wheel for dlib fatal error: Python.h: No such file or directory This is because missing python3-dev package. To fix, install apt install python3-dev If you are using python virtualenv, you will need to recreate the virtualenv after installing dev package. virtualenv -p /usr/bin/python3 venv

ERROR: Failed building wheel for mysqlclient

When install mysqlclient python module, i get error (venv) boby@sok-01:~/Downloads/django-deploy$ pip install mysqlclient==1.4.2.post1 Collecting mysqlclient==1.4.2.post1 Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) … error ERROR: Complete output from command /home/boby/venv/bin/python3 -u -c ‘import setuptools, tokenize;__file__='”‘”‘/tmp/pip-install-bbfa8tuo/mysqlclient/setup.py'”‘”‘;f=getattr(tokenize, ‘”‘”‘open'”‘”‘, open)(__file__);code=f.read().replace(‘”‘”‘\r\n'”‘”‘, ‘”‘”‘\n'”‘”‘);f.close();exec(compile(code, __file__, ‘”‘”‘exec'”‘”‘))’ bdist_wheel -d /tmp/pip-wheel-bqlba1jk –python-tag cp36: ERROR: running bdist_wheel … Read more

pip install mysqlclient mysql_config: not found

On Ubuntu 18.04, when i install mysqlclient python module, i get error (venv) boby@sok-01:~/Downloads/django-deploy$ pip install mysqlclient==1.4.2.post1 Collecting mysqlclient==1.4.2.post1 Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz ERROR: Complete output from command python setup.py egg_info: ERROR: /bin/sh: 1: mysql_config: not found Traceback (most recent call last): File “”, line 1, in File “/tmp/pip-install-we5rsid9/mysqlclient/setup.py”, line 16, in metadata, options = get_config() … Read more