I am trying to install mysqlclient for python in my virtualenv. It fails with the following:
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
After some research, i found out that i require python-dev installation. I have it installed in my main directories (i.e /usr/bin ... ) but its not installed virtualenv but each time i type:
sudo apt-get install python-dev
I get the following response:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 453 not upgraded.
Showing its availability, outside the virtualenv mysqlclient installs properly. The issue is how to rectify python-dev installation into the virtualenv
Installing virtualenv venv is included in the Python standard library and requires no additional installation. If you are using venv, you may skip this section. virtualenv is used to manage Python packages for different projects.
By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.
Just put a file with a . pth extension (any basename works) in your virtualenv's site-packages folder, e.g. lib\python2. 7\site-packages , with the absolute path to the directory containing your package as its only contents.
I am currently having issue in Ubuntu 20 where the default python is python 3.8. This causes issue when I try to install Pillow in a virtualenv created by pipenv
that need to use python 3.9.
The simplest solution I found so far is to install python-dev for 3.9
sudo apt install python3.9-dev
Previously I install python3-dev
which always default to 3.8
Maybe not the best way but my solution was installing miniconda. You can also probably try the larger Anaconda distribution. I believe these distributions have built-in python-dev.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With