I am new to django and python in general, so pardon me for any simple mistakes I may be doing. I am trying to setup my first django project on my local windows vista machine. I have created the project successfully with no problems. The issue I am coming across is when my settings.py has values for my database keys, the manage.py runserver command is failing. If I have values in settings before I run the command, as soon as I run it I get errors. If I have already run the command and the server is running, as soon as I edit the settings file with values, the errors show up in my still open command prompt. The inner most exception seems to "Error loading MySQLdb module: No module named MYSQLdb". If I leave the settings.py blank, the command executes with no problems.
Any advice would be greatly appreciated!
Thanks
You don't have mysql-python module installed, thats why you getting that error.
You could find that module at
http://pypi.python.org/pypi/MySQL-python/
Install the MySQLdb module, or the oursql module along with the django-oursql connector.
Related
I have a mysql database for my django project. Had also installed XAMPP for local development. While deploying I did. I think there's a problem with the python version of my pthonanywhere bash console. My project can support only python 3.7 because of the kiteconnect module that I am using.
I have installed kiteconnect, mysqlclient, and mysql connector (checked it with pip3 freeze too)
pa_autoconfigure_django.py --python = 3.7 <git-repo-url>
I set up my database and made the changes suggested in my settings.py file in DATABASE, (changed hostname, database name, passowrd, PORT:3306, etc). I am getting this error in logs:
Error running WSGI application
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
Please help me. This is a project I'm working on. Will be happy to provide further inputs too.
pa_autoconfigure_django creates a virtualenv using the requirements.txt file in your project. If you do not have mysqlclient in your requirements.txt file, then it will not be installed in the virtualenv.
I followed the set of instructions for this open source.
At step 3, I am supposed to run
py.test tests/functional/
When I do so, I get
ModuleNotFoundError: No module named 'textx'
However, when I type textx, it's definitely working as a command.
Where did I go wrong?
The PYTHONPATH is not set by py.test, see https://docs.pytest.org/en/latest/pythonpath.html#pythonpath
As described in https://github.com/igordejanovic/textX/blob/master/CONTRIBUTING.md you install textX in your virtual environment. If you omit 'pip install -e .' you get the described behavior.
As mentioned above, you can set the PYTHONPATH manually. Alternatively you can also run 'python -m pytest tests/functional' as proposed on the py.test website.
It is unclear to me why the textx command works in your example. Maybe you installed textX outside your virtual environment after creating the virtual environment?
Run export PYTHONPATH=. before running the py.test tests/functional/ and it should work.
This error may have occurred because I installed textX outside my virtual environment after creating the virtual environment.
I had an py27 application running on aws ElasticBeanStalk for over a year. Recently it stopped working. So I tried to redeploy. During redeploy I got the following error in the logs:
Return code: 1 Output: [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/03deploy.py]
command failed with error code 1:
/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py
New python executable in /opt/python/run/venv/bin/python27
Not overwriting existing python script /opt/python/run/venv/bin/python
(you must use /opt/python/run/venv/bin/python27)
Can somebody tell me where I will find /opt/python/run/venv/bin/python? How can I change it to
/opt/python/run/venv/bin/python27?
Thanks
When you redeployed, you opted into the latest beanstalk version, which uses a different AMI than the one originally used. If you're familiar with the concept of ebextensions then you're probably looking to add a file like this:
.ebextensions/python.config:
ln -s /opt/python/run/venv/bin/python27 /opt/python/run/venv/bin/python
I am using flask. I installed Flask-migrate and have been using it to migrate my postgresql db. It works fine on my local box. However, when I run it on openshift I get an error
"File "/opt/rh/python27/root/usr/lib64/python2.7/ConfigParser.py", line 396, in set
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'alembic'
"
Anyone know what this is or how to fix it?
It probably means that Flask Migrate is unable to find alembic configuration. Flask Migrate depends on Alembic to generate db revisions.
By default, Flask Migrate searches for configuration(and db version scripts) in migrations directory. If your configuration is present in different folder, you can specify it using -d <dir>
I think this is a bug with LD_Library_path that should be fixed in this sprint. Should be rolling out to production in a week or two
I'm beginning to use Grunt.js to manage my workflow for repeated tasks and right now I'm stuck on database deployment (a huge source of potential errors for me).
I've installed the grunt-deployment package and I can pull down the remote database, as well as push to it (theoretically). However locally I get the error:
/bin/sh: mysql: command not found
Or
/bin/sh: mysqldump: command not found
I'm not sure where I should be adding those commands, or how. I'm also using AMPPS for my local development.
The environment I'm in is Mac OS X, using AMPPS as my apache/mysql server.
Put AMPPS MySQL in PATH environment and all should be fine.
export PATH=$PATH:/Applications/AMPPS/mysql/bin