from flask_mysqldb import MySQL - mysql

EDIT: Problem resolved. I was able to finally figure out the problem with some help from another student in the Udemy class along with the answer from Isaac_R here. I had to edit my .bash_profile with the following two lines of code and I am able to install MySQLdb and it is working as intended now. Here are the two lines I added to my .bash_profile
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
EDIT #2: I just started another mysql project in a new file, I had to run
pip3 install mysqlclient
before I could install mysqldb, just a heads up to someone who may have this issue like I did.
I am totally new to coding so please excuse my potential ignorance, I am trying my best to learn something new and it was going well until I ran into this issue that I am unable to get passed. I am on a Mac with 10.15.4 in python3.8.2 trying to create a MySQL database in order to use in a blog I am attempting to build. I have installed the mysql client along with pip3 install flask-mysqldb. I get successful conformation of the install, here is where my problems start. In Atom I am using the command from ''flask_mysqldb import MySQL'' to which I receive the error of the following
Traceback (most recent call last):
File "app.py", line 3, in <module>
from flask_mysqldb import MySQL
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_mysqldb/__init__.py", line 1,
in <module>
import MySQLdb
File "IndentationError: unexpected indent
(venv) tylernelson#Tylers-MacBook-Air My Project % python3 app.py
Traceback (most recent call last):
File "app.py", line 3, in <module>
from flask_mysqldb import MySQL
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_mysqldb/__init__.py", line 1,
in <module>
import MySQLdb
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <
module>
from . import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-
38-darwin.so, 2): Library not loaded: #rpath/libmysqlclient.21.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-3
8-darwin.so
Reason: image not found"
I am able to post my entire (all be it super short) code file also if that will help resolve the problem. Thank you so much for your ideas and help!

I went thru the same issue, I found the best solutions within this question:
Python mysqldb: Library not loaded: libmysqlclient.18.dylib
I will recommend you to go thru all the options listed there, in my case run the command
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
solved my issues, most of the time when mysql gets installed the mysql directory should be renamed to just mysql.

Related

PyModbusTCP module installation on windows pc

Last year, I made a program using the PyModbusTCP module on a raspberry Pi. Now I want to try my programs again on a windows pc but I can't seem to get my installations correct.
Here is some info:
project has a venv folder and a main.py next to it. I am not sure if the main.py has to be in the venv folder or not.
PyModbusTCP has been installed using git cmd with the command "pip3 install pyModbusTCP" and gives me a message "requirement already satisfied..."
Message in console after using a basic program provided by the pymodbustcp dev:
C:\Users\SESA681397\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\SESA681397\PycharmProjects\pythonProject\test.py
Traceback (most recent call last):
File "C:\Users\SESA681397\PycharmProjects\pythonProject\test.py", line 1, in <module>
from pyModbusTCP.client import ModbusClient
ModuleNotFoundError: No module named 'pyModbusTCP'
Thank you for your time reading this, it is probably a stupid problem but i don't know it.
I tried to get the folder correctly and see if pymodbustcp module is correctly installed.
Tried to see if the module is installed and if my previous programs worked.

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 ...

how to install pygobject for python3 in fedora18

i try to install pygobject for python 3 in fedora 18
i read this doc https://python-gtk-3-tutorial.readthedocs.org/en/latest/install.html and i try to install jhbuild after that when i type $ jhbuild sanitycheck
get this error : bash: jhbuild: command not found...
i try to install with yum , i install "pygobject3-devel" but this not work with python3
in fedora 18 default python is python2.7.3, i install python3.3.0 with yum and test a first demo code :
#!/usr/bin/python
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
after give chmod +x for this python file can run with this command "./test.py"
and if i try to run with python (with out use #! ....) and type this command "$python test.py" that run and work without any problem but when i type this command "$python3 test.py" i get this error :
Traceback (most recent call last):
File "test.py", line 2, in <module>
from gi.repository import Gtk
ImportError: No module named 'gi'
have any idea ?
thanks
Try installing pygobject3 instead of pygobject3-dev (as a matter of fact, it seems that pygobject3 is already installed in a vainilla installation of Fedora).
After installing that package, you should be able to open your interpreter (python2.7) and do:
from gi.repository import Gtk
If you want to use python3 (I didn't understand if you meant that you tried to use python3 or you want to use python3), it seems that the gnome instrospection bindings are not yet available, according to this page that summarizes the state of different packages python3-related that are being on the works.
EDIT: I just tried installing python3-gobject (which should be installed when installing pygobject3, but it doesn't for some reason) and it seems to be working aswell on python3.

Can't import MySQLdb module in Python

I'm trying to use MySQL in Python. I have installed the MySQL adapter (MySQL-python-1.2.4b4.win32-py2.7) for Python, but when I try to import the MySQLdb module (import MySQLdb) with command prompt I receive the following output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: %1 is not a valid Win32 application.
Would anybody know, what could be wrong?
You need to have a 32bit version of Python to use this adapter. Which version are you actually using ?
I had problems installing the 64-bit version of MySQLdb on Windows via Pip, but if you want to continue using a 64-bit version of Python, rather than reverting to a 32-bit version, then you can install the compiled MySQLdb from the .whl file available from http://www.lfd.uci.edu/~gohlke/pythonlibs/
You will then want to install the .whl file as document in https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
when you setup the module ,be careful the version ,MySQL-python-1.2.3.win32-py2.7.exe and MySQL-python-1.2.4.win32-py2.7.exe ,only one of the 2 version is you need,try 2 times