I'm building an application that is using python-magic 0.4.15. On my local machine, python-magic-bin 0.4.15 works like a charm (Windows) but I'm trying to make it work on Heroku. First I'm just trying to get the tests to pass in the Heroku-CI. I added the package to my requirements.txt:
python-magic==0.4.15
And pushed it to Heroku. And it gets installed correctly:
-----> Installing requirements with pip
Collecting python-magic==0.4.15 (from -r /app/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl
Installing collected packages: python-magic
Successfully installed python-magic-0.4.15
But then it crashes like this:
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
I tried adding the NetsoftHoldings/heroku-buildpack-magic buildpack and I can see it's being downloaded:
-----> Fetching https://github.com/NetsoftHoldings/heroku-buildpack-magic.git buildpack...
buildpack downloaded
The pip package is being correctly installed:
-----> Installing requirements with pip
Collecting python-magic==0.4.15 (from -r /app/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl
Installing collected packages: python-magic
Successfully installed python-magic-0.4.15
but then there seems to be an error with the buildpack (I'm guessing here):
-----> libmagic app detected
bash: /tmp/buildpacks/27353aa3b5edb2f8361186206e863f5d481f02805d02f0efdec439f3d30349a4fbdad2951af33a0492023fb0d90d26dafda6fe76f1b2d34f68564a98545f7022/export: No such file or directory
RootDir: /tmp/buildpacks/ba9220b10d71b7b776013869da2c820ccb5c0f1733268ae2515b3b8ad5edd44d2016d1119bce32d1660fbd84da179891a404dcc57df043b9d82e22725739b072
BuildDir: /app
HOME: /app
Build list
config
Home list
config
and it eventually crashes like this:
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
Then I tried adding the heroku-community/apt buildpack and an Aptfile containing:
libmagic-dev
libmagic1
and I can see them being installed correctly:
-----> Fetching .debs for libmagic-dev
Reading package lists...
Building dependency tree...
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
Need to get 79.4 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 libmagic-dev amd64 1:5.32-2ubuntu0.1 [79.4 kB]
Fetched 79.4 kB in 0s (222 kB/s)
Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Fetching .debs for libmagic1
Reading package lists...
Building dependency tree...
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
Need to get 68.4 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.1 [68.4 kB]
Fetched 68.4 kB in 0s (199 kB/s)
Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Installing libmagic1_1%3a5.32-2ubuntu0.1_amd64.deb
-----> Installing libmagic-dev_1%3a5.32-2ubuntu0.1_amd64.deb
But the application still fails with the same error:
+ pip install -r requirements-test.txt
Requirement already satisfied: coverage==4.5.1 in ./.heroku/python/lib/python3.6/site-packages (from -r requirements-test.txt (line 1))
Requirement already satisfied: selenium==3.141.0 in ./.heroku/python/lib/python3.6/site-packages (from -r requirements-test.txt (line 2))
Requirement already satisfied: urllib3 in ./.heroku/python/lib/python3.6/site-packages (from selenium==3.141.0->-r requirements-test.txt (line 2))
You are using pip version 9.0.2, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
+ python manage.py collectstatic --no-input
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/core/admin.py", line 8, in <module>
from .forms import CrmDataUploadForm
File "/app/core/forms.py", line 3, in <module>
from magic import magic
ImportError: cannot import name 'magic'
Any ideas how to get python-magic working on Heroku?
The correct way to import the magic module is:
import magic
not
from magic import magic
python-magic just provides a magic module and python-magic-bin does the same. The problem is that python-magic-bin has a package called magic that imports the module magic.magic, which is sort-of like an internal detail, hence, the latter example works in python-magic-bin but not python-magic.
From the python-magic documentation:
>>> import magic
>>> magic.from_file("testdata/test.pdf")
'PDF document, version 1.2'
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
Related
I tried installing the AioHttp package, as seen in the extract below. The installation failed with the multidict module.
root#ava:/home/cliquant/server/ava# pip3 install aiohttp
Collecting aiohttp
Using cached https://files.pythonhosted.org/packages/ff/4f/62d9859b7d4e6dc32feda67815c5f5ab4421e6909e48cbc970b6a40d60b7/aiohttp-3.8.3.tar.gz
Complete output from command python setup.py egg_info:
*********************
* Accelerated build *
*********************
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-0b29nbfp/aiohttp/setup.py", line 54, in <module>
setup(**setup_kwargs)
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.6/distutils/core.py", line 121, in setup
dist.parse_config_files()
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 494, in parse_config_files
ignore_option_errors=ignore_option_errors)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 106, in parse_configuration
meta.parse()
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 382, in parse
section_parser_method(section_options)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 355, in parse_section
self[name] = value
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 173, in __setitem__
value = parser(value)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 430, in _parse_version
version = self._parse_attr(value)
File "/usr/lib/python3/dist-packages/setuptools/config.py", line 305, in _parse_attr
module = import_module(module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/pip-build-0b29nbfp/aiohttp/aiohttp/__init__.py", line 5, in <module>
from . import hdrs as hdrs
File "/tmp/pip-build-0b29nbfp/aiohttp/aiohttp/hdrs.py", line 8, in <module>
from multidict import istr
ModuleNotFoundError: No module named 'multidict'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0b29nbfp/aiohttp/`
I got error when installing aiohttp with pip3.
How can I fix this?
NB: I can't find in google about it...
Google came to your aid narrowing down on the ModuleNotFoundError: No module named 'multidict'
To resolve, install the multidict module.
python3 -m pip install multidict or
pip3 install multidict
See this GitHub issue #277, and
this SO question
[Edit] For completeness, ensure you are installing in the correct environment env.
Also, check the version(s) of python installed on the system.
This week I started working home and tried installing my project on my PC but it won't work.
I cloned the git repo, installed MySQL Workbench and Server and stuff, installed Visual C++ stuffs
and loads of modules from my requirements.txt.
But when I try to run ./manage.py migrate it spits out this:
$ py manage.py migrate
Traceback (most recent call last):
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\backends\mysql\base.py", line 15, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\lisa-\projects\register\manage.py", line 22, in <module>
main()
File "C:\Users\lisa-\projects\register\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\apps\config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\lisa-\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\contrib\auth\base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\models\base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\models\base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\models\options.py", line 207, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\utils.py", line 204, in create_connection
backend = load_backend(db['ENGINE'])
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\lisa-\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\lisa-\projects\register\venv\lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module>
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
Now I did install mysqlclient:
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.1.0-cp310-cp310-win_amd64.whl (180 kB)
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.1.0
All of this is happening with a newly made venv using python 3.10, Django 3.2.7 and SQL Server 8.0
I googled about 2 hours which didn't help at all, because all I could find was "use pip install mysqlclient", which I obviously did. Sometimes I find things like "install using a wheel file". But I can't find a wheel file for 3.10. Or "use pip install mysql-python" or something like that but then I get an error saying I need Visual C++ 14.0, which I'm pretty sure I have...
So, I'm lost. Please please help me out.
When I am trying to migrate file to Heroku master (deploying to Heroku)
These errors comes:
(test) C:\Users\DELL\Desktop\django-project\imageapi>heroku run python manage.py migrate
Running python manage.py migrate on ⬢ imageapii... up, run.9341 (Free)
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line
File "/app/.heroku/python/lib/python3.9/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/app/imageapi/urls.py", line 18, in <module>
from core.views import TextView,fetching
File "/app/core/views.py", line 3, in <module>
import cv2 as cv
File "/app/.heroku/python/lib/python3.9/site-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
and my pip list :
Package Version
------------------- ---------
asgiref 3.4.1
certifi 2021.5.30
chardet 4.0.0
dj-database-url 0.5.0
Django 3.2.5
django-cors-headers 3.7.0
django-heroku 0.3.1
djangorestframework 3.12.4
gunicorn 20.1.0
idna 2.10
numpy 1.21.0
opencv-python 4.5.2.54
Pillow 8.3.0
pip 21.1.3
psycopg2 2.9.1
pytz 2021.1
PyYAML 5.4.1
requests 2.25.1
setuptools 57.0.0
sqlparse 0.4.1
uritemplate 3.0.1
urllib3 1.26.6
wheel 0.36.2
whitenoise 5.2.0
I am doing this on window 10 and not using Docker.I tried many answer regarding this error but none of them was useful.
pls help me :(
Thanks in advance
I'm Deploying a Django Application on an AWS instance (amazon2 64-bit, Linux/4.14.128-112.105.amzn2.x86_64). I spent a lot of time looking and searching in stack overflow without finding a solution.
My problem: correctly install mysqlclient.
The error:
mod_wsgi (pid=14418): Failed to exec Python script file '/var/www/html/project_x/project_x/wsgi.py'.
mod_wsgi (pid=14418): Exception occurred processing WSGI script '/var/www/html/project_x/project_x/wsgi.py'.
Traceback (most recent call last):
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: cannot import name '_mysql'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/www/html/project_x/project_x/wsgi.py", line 17, in <module>
application = get_wsgi_application()
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/var/www/html/project_x/projectenv/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
I've installed everything, but it doesnt work.
I created the virtual environment inside the projects folder:
$ virtualenv projectenv --python=python3.7
$ source projectenv/bin/activate
After that I've installed the plugins with pip:
$ pip list
Package Version
----------- -------
Django 2.2.5
mysqlclient 1.4.4
pip 19.2.3
pytz 2019.2
setuptools 41.2.0
sqlparse 0.3.0
wheel 0.33.6
As you can see, the packages are correctly installed. Also msqlclient is installed. I don't know what else to do, I've consulted a lot of posts on Stackoverflow, but none of them have solved my problem.
I have encountered same problem. I am not sure about AWS but I was having problem on my Mac. So what happens is that security of Mac do not let that settings access the file MySQLdb._mysql. So,I just run the command sudo cp -r /usr/local/mysql/lib/* /usr/local/lib/ and after running command python manage.py migrate, it worked. Hope my answer finds the solution you're looking for. Have a nice day!
I am trying to install readthedocs in local system (Ubuntu 14.04 ) in python3 virtual env from the instructions given in this link
When I ran pip3 install -r requirements.txt , I got an error for Distutils2 . I removed that dependency as the distutils2 is no longer supported and assumed setuptools would suffice.
Running this command python manage.py migrate gave the below error :
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/username/read_the_docs_env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/admin.py", line 10, in <module>
from readthedocs.core.views import SendEmailView
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/views/__init__.py", line 26, in <module>
from readthedocs.projects.tasks import remove_dir
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/projects/tasks.py", line 493
print "Sync Versions Exception: %s" % e.message
^
SyntaxError: Missing parentheses in call to 'print'
I understand from the above stacktrace that the code is in python2 and so print statement is different in python3 .
Does this mean that I have to install readthedocs in python2 virtualenv ?
Can't we host the docs of python3 projects in readthedocs in-house server ?
The read the docs code does not support Python 3 yet. The installation instructions explicitly say to use Python 2.7:
First, obtain Python 2.7 and virtualenv
However, it should still be possible to use your read the docs installation to host docs for Python 3 projects, since the instructions then say:
If you plan to import Python 3 project to your RTD then you’ll need to install Python 3 with virtualenv in your system as well.