What do we have:
Django app hosted on Pythonanywhere with sqlite db initialized
MySql DB activated on Pythonanywhere (it provided me with db name, pasword and host - everything that I need to setup settings.py)
pip install mysqlclient finished successfully
python manage.py makemigrations - DONE
python manage.py migrate - DONE
mysql console on Pythonanywhere shows all my tables created
but restarting app causes pythonanywhere error page and link to error log
2020-08-15 17:22:56,536: Error running WSGI application
2020-08-15 17:22:56,569: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
2020-08-15 17:22:56,569: Did you install mysqlclient?
So the question is how could it be possible? As i got it right migrations are used mysqlclient to manipulate DB, how can it be not installed?
Might be someone did face with similar issue?
you need to install mysql client, but that might also throw an error, so you need to install it using its wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and keep installing every wheel incase an error occurs.
Related
ModuleNotFoundError: No module named 'django_on_heroku'
I've got a new machine at work and I'm attempting to run an old project which I've cloned. Cannot get the api server up and running.
(ps, my first stack overflow post -- sorry if the format isn't great or specific enough!)
Have tried installing django on heroku in the pipenv - that is sucesfull, the error reoccurs though on the next dependency when i attempt a migrate and then run server.
I am currently trying to deploy a Python/Django app to Heroku. The build was successful however, I am attempting make a migration to an established postgresql database to connect it to Heroku remote.
When I run:
heroku run python manage.py migrate
I get the following error:
ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
The Django environment is currently activated in my terminal screen.
I ran python to get the version type then ran print(sys.path which showed the Django environment listed. Just for giggles I ran pip install django once again, where a message stating requirement already satisfied came up.
So it looks like django is installed, my virtual environment is working, but I cannot make the migration for Heroku...
Any advice appreciated.
I am trying to deploy my python web application to Heroku and I am using the postgresql database to store user information such as login credentials etc. My app has been deployed but I am trying to create the database table by running the commands
Heroku run python
from app import db
db.create_all()
However, when I run that in my terminal, I receive this error message.
ModuleNotFoundError: No module named 'psycopg2'.
I have tried to run pip install pyscopg2 and then I receive this error
Error: pg_config executable not found.
I have also ran the command pip install psycopg2-binary and receive the same error. Any explantation for how I can resolve this... Many thanks in advance
Add a file in the root directory of your project named requirements.txt with the following contents:
psycopg2
Heroku also reccommends adding a version number like so:
psycopg2==2.9.3
Learn more here: https://devcenter.heroku.com/articles/python-pip
I'm trying to connect my Django app with MySQL and I have Successfully installed MySQL-connector-python-2.0.4 also. But after that whenever I run server same error message is showing.
Here are my cmd ...
Here is the full message showing
you are installing MySQL connector for python (not recommended), you need the MySQLdb module, refer to this official recommendation from django doc https://docs.djangoproject.com/en/3.0/ref/databases/#mysql-db-api-drivers
and install mysqlclient it is a native driver and It’s the recommended choice.
pip install mysqlclient
for further informations have a look at this medium post : https://medium.com/#omaraamir19966/connect-django-with-mysql-database-f946d0f6f9e3
I need help switching my database engine from sqlite to mysql. manage.py datadump is returning the same error that pops up when I try to do anything else with manage.py : ImproperlyConfigured: Error loading MySQL module, No module named MySQLdb.
This django project is a team project. I pulled new changes from bitbucket and our backend has a new configuration. This new configuration needs mysql (and not sqlite) to work. Our lead dev is sleeping right now. I need help so I can get started working again.
Edit: How will I get the data in the sqlite database file into the new MySQL Database?
According to the Database setup paragraph in Django docs:
By default, the configuration uses SQLite.
If you wish to use another database, install the appropriate database
bindings...
And Get your database running page says:
If you’re using MySQL, you’ll need the MySQL-python package, version
1.2.1p2 or higher.
To use MySQL backend you need a tool that would help Django talk to the database, an adapter.
In other words, MySQL-python (aka MySQLdb) package needs to be installed.
Try the followings steps:
1. Change DATABASES in settings.py to MYSQL engine
2. Run $ ./manage.py syncdb