I have successfully installed a Django project on my CentOS 6.9. I have installed the project in a virtual environment which I have created using python3.6 python3.6 -m venv env
I have activated the virtual env and I am now trying to run the app using;
python manage.py runserver 0.0.0.0:8000
When I run this command I get the following error;
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7f7c5d67b8>
Traceback (most recent call last):
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 26, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/REMOVED/REMOVED/python3.6/softwareix/storefront/models.py", line 10, in <module>
class Brand(models.Model):
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/base.py", line 331, in add_to_class
value.contribute_to_class(cls, name)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/REMOVED/REMOVED/python3.6/env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
I see that I am missing Python mysql extension or driver. I have attempted to install it as suggested. When I run; pip install mysqlclient
I get;
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /REMOVED/REMOVED/python3.6/env/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7g3likz_/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-y1mak800-record/install-record.txt --single-version-externally-managed --compile --install-headers /REMOVED/REMOVED/python3.6/env/include/site/python3.6/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/include/mysql -I/REMOVED/REMOVED/python3.6/env/include -I/usr/local/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
gcc: error trying to exec 'as': execvp: Permission denied
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/REMOVED/REMOVED/python3.6/env/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7g3likz_/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-y1mak800-record/install-record.txt --single-version-externally-managed --compile --install-headers /REMOVED/REMOVED/python3.6/env/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-build-7g3likz_/mysqlclient/
This does not seem to work. I have tried to install severally packages using yum after searching the internet. I tried to install yum install python3-devel
but this is not available ( No package python3-devel available.
) and I see it is supposed to be in the epel repository. So I did yum search python dev
and I get this;
dbus-python-devel.x86_64 : Libraries and headers for dbus-python
gstreamer-python-devel.x86_64 : Headers for developing programs that will use gstreamer-python
libimobiledevice-python.x86_64 : Python bindings for libimobiledevice
pyldb-devel.x86_64 : Development files for the Python bindings for the LDB library
python-behave.noarch : Tools for the behavior-driven development, Python style
python-cherrypy.noarch : Pythonic, object-oriented web development framework
python-cherrypy2.noarch : Pythonic, object-oriented web development framework
python-devel.x86_64 : The libraries and header files needed for Python development
python-devel.i686 : The libraries and header files needed for Python development
python-igraph-devel.x86_64 : Development files for igraph
python-imaging-devel.x86_64 : Development files for python-imaging
python-mozdevice.noarch : Mozilla-authored device management
python-pyblock.x86_64 : Python modules for dealing with block devices
python-pyldns.x86_64 : Header files, libraries and development documentation for ldns.
python-pyside-devel.i686 : Development files for python-pyside
python-pyside-devel.x86_64 : Development files for python-pyside
python-tools.x86_64 : A collection of development tools included with Python
python34-devel.i686 : Libraries and header files needed for Python 3 development
python34-devel.x86_64 : Libraries and header files needed for Python 3 development
wxPython-devel.i686 : Development files for wxPython add-on modules
wxPython-devel.x86_64 : Development files for wxPython add-on modules
python-pycxx-devel.noarch : PyCXX header and source files
This is what I have tried so far. I am trying to get my Django app running on MySQL but the extension or module does not appear to be installed.
The gcc: error trying to exec 'as': execvp: Permission denied
diagnostic is fairly clear. Use which as
to verify you haven't put another file named as
on your $PATH
. You want to get to the point where you can successfully compile a simple hello.c
Hello World program, which involves gcc
producing assembly code, and as
turning that into intel x86 object code. Try this:
sudo yum install gcc binutils-devel
Verify it succeeded by running which as; as --version
which as; as --version
and seeing a banner like "GNU assembler (GNU Binutils for Ubuntu) 2.27".
You currently do not have permissions to pip install mysqlclient
. Since this is centos, you probably don't want to use pip
(unless you set up a virtualenv
). You want to run yum install mysql-python
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.