Django Elastic Beanstalk to RDS MySQL problems connecting - mysql

I'm trying to connect my Django Elastic Beanstalk to my RDS MySQL. My Django works with my RDS MySQL through localhost, but when trying to upload my Django to Elastic Beanstalk I get "failed to deploy application" and AWS shows errors (below). My project has mysqlclient in requirements.txt, like here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html
According to that page, that should be enough. I've of course tried to search for similar questions but haven't had success so far. I've noticed that many questions refer to needing a packages.config file inside .ebextensions, I tried many of those suggestions without success. Is that the problem? Why wouldn't that be mentioned on the AWS page?
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
[end of output]

Answering my own question. I asked something similar later AWS Elastic Beanstalk RDS MacOS mysqlclient not working and got help.
The answer was indeed the packages.config file with yum installing the necessary files (check the link above). There was something off somewhere else in my code but the errors that I got were the same as above, even though packages.config was setup properly. I figured it out because I tried to set it back to the SQLite database and upload it to Elastic Beanstalk and it didn't work. (I don't remember what errors I got sorry, I was stressed out, I think the "111: Connection refused" errors again though.)
The way I got things working was to delete all of my configuration files and start again from the regular finished project and then follow the tutorials (like I was doing before): https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html#python-rds-connect
From there, I added a packages.config file inside my .ebextensions folder with the following code...
packages:
yum:
python3-devel: []
mariadb-devel: []
...as is noted in my other question linked to above as well as here: mysqlclient installation error in AWS Elastic Beanstalk
I also needed gunicorn and a Procfile, I had that problem solved before anyway but it's worth mentioning in case you're here because of problems with Elastic Beanstalk and RDS.
I also didn't understand if I could use yum in the packages.config file if I didn't have it on my computer, especially since I use MacOS and it's not common to use yum on MacOS. That question was answered in my other question linked to at the top of this answer, the answer being that you do not need yum on your computer in this case, because yum is being used in this case by the Amazon Linux 2 server from Elastic Beanstalk.

Related

Pygame auto-py-to-exe gets stuck after selecting script location [duplicate]

I try to install Auto-Py-to-exe but they have a lot of error appear during the installation but at the end it sais successfully installed, see picture below.
I have windows 10pro, PyCharm community 2020.3.3, and i use python 3.9.1 for almost all my projects.
I have uninstall auto-Py-to-exe, piwin, PYpiwin32, pywin32, PyInstaller. Close all the system and reboot, re-install all these module, but nothing seem to work. It the same error when i use Python 3.6 or 3.7. the same error arrived in PyCharm terminal and in the promt(cmd) window terminal.
C:\Windows\system32>auto-py-to-exe
Traceback (most recent call last):
File "c:\users\mélissa\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None, File "c:\users\mélissa\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals) File "C:\Users\Mélissa\AppData\Local\Programs\Python\Python39\Scripts\auto-py-to-exe.exe\__main__.py", line 7, in <module>
File "c:\users\mélissa\appdata\local\programs\python\python39\lib\site-packages\auto_py_to_exe\__main__.py", line 291, in run
if eel.chrome.get_instance_path() is not None and not disable_chrome:AttributeError: module 'eel.chrome' has no attribute 'get_instance_path'
C:\Windows\system32>
I have made the update of PIP, EEL, PYInstaller( the upper version they want to install is 3.2.1, the other fail), gevent and greenlet but i receive always the same error message.
I don't know what to do. I have check here for answer or direction to resolve my problem but i find nothing for now.
the error message in PYCharm, it the same in window terminal
It appears, while looking at the traceback, that the error is in the source code, and not your own execution. Looking through the auto-py-to-exe GitHub repository files, it seems that the package just uses pyinstaller to convert the python script(s) to executable files. In this case, I would recommend just using pyinstaller itself.
To convetr the .py file to a single file, run:
pyinstaller my_script.py --onefile --windowed
The .exe file will appear in a folder dist/ (created during the build). The build/ folder along with other files created during the process can be deleted.

Django MySQL throws an error, Library not loaded: /usr/local/opt/mysql#5.6/lib/libmysqlclient.18.dylib When I upgraded from 5.6 to 5.7 mysql

Yes, this seems like a common error. But something else is wrong with my environment. I have upgraded from MySQL 5.6 version to 5.7.
I can access mysql5.7 by typing mysql into the console.
I have updated the DYLD_LIBRARY_PATH to reflect new 5.7 location
git:(parent-child) ✗ echo $DYLD_LIBRARY_PATH
/usr/local/opt/mysql#5.7/lib/:
But the error for reason still says it is trying to load from 5.6 version.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/vineeth/envs/automize2.0/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module>
import MySQLdb as Database
File "/Users/vineeth/envs/automize2.0/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: dlopen(/Users/vineeth/envs/automize2.0/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql#5.6/lib/libmysqlclient.18.dylib
Referenced from: /Users/vineeth/envs/automize2.0/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
Reason: image not found
Notice the error says it still is trying locate /usr/local/opt/mysql#5.6/lib/libmysqlclient.18.dylib
I have reinstalled almost everything since this error came.
Tried several solutions
Python mysqldb: Library not loaded: libmysqlclient.18.dylib
rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib
Nothing seems to change its reference.
How do I make it refer to the newer one which is in /usr/local/opt/mysql#5.7/lib/
Also reinstalled mysqlclient with pip but still no luck.
Help is welcome. Been struggling since a day.
To expand my comment as an answer:
Pip compiles source packages into wheels that get cached into your local Pip cache. However, it has no knowledge of the "ambient" dependencies that may affect how the binary package gets compiled, in this case the MySQL shared library.
Recreating the virtualenv won't directly help, since Pip will use the cached binary wheel (to save you from a recompilation).
You could:
use pip install --no-cache-dir to have Pip not use the cache at all (though the "tainted" wheel will remain in your cache)
nuke the whole Pip cache from orbit
see what comes out of https://github.com/pypa/pip/issues/2882 / https://github.com/pypa/pip/issues/4685 ...

ImportError: No module named fabric when run mysqlfabric command

My VM is using Ubuntu 14.04.
I followed the official manual to install MySql Fabric:
First, install Connector/Python GA
Next, install MySQL Utilities 1.5.6
However, when I tried to test the mysqlfabric help command, it threw error like:
Traceback (most recent call last):
File "/usr/bin/mysqlfabric", line 33, in <module>
from mysql.fabric import (
ImportError: No module named fabric
Based on this SO question, after upgrading Ubuntu from 15.04, the problem can be resolved, but I want to run fabric on Ubuntu 14.04.
I tried to re-installed Connector/Python, MySQL Utilities, also checked compatibility with Ubuntu version 14.04, searched on the Internet & SO for similar problems. But still cannot resolve the issue.
Thanks a lot for your help!
Not quite sure what is the problem with installing using .deb file.
But after many (painful) tries, I figured out that re-installing MySQL Utilities from source code can resolve the issue.

Installing Cairo and PyCairo Mac OsX

I am playing around with using python iGraph for network visualization. I got his error message when I tried to plot a graph:
>>> layout = g.layout("kk")
>>> plot(g, layout = layout)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 446, in plot
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 117, in __init__
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/utils.py", line 396, in __getattr__
TypeError: plotting not available
I don't think I installed Cairo or PyCairo correctly.
I am not familiar using Fink or MacPorts, since I commonly use Homebrew.
Any help you be greatly appreciated.
You need to manually compile the library. I used the solution here and just updated the version.
curl -L https://www.cairographics.org/releases/cairo-1.14.6.tar.xz -o cairo.tar.xz
tar -xf cairo.tar.xz && cd cairo-1.14.6
./configure --prefix=/usr/local --disable-dependency-tracking
make install
If while running configure, you get an error about pkg_config, you can install that with brew:
brew install pkg-config
I had the same problem on my MacBook so I wanted to share my solution.
I tried to install pycairo, py2cairo. The installation seemed to be okay but then:
I could not import pycairo
igraph's plot would not work.
The following solved the igraph plotting issue:
sudo pip install cairocffi
or just
pip install cairocffi
So instead of pycairo I used cairocffi and this did the trick.
As Mads said in a comment, brew install cairo works, it solved a related problem for me, so I'm posting here for people who end up here why troubleshooting cairo on OS X.
Accepted answer lead to an error of libpng missing, homebrew on the other hand installed all dependencies correctly.

Grunt Deployments /bin/sh: mysql: command not found

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