In the process of downloading mysql connector, I've taken 3 approaches:-
The commonly advised pip approach where I think the PATH (Python on system; which I don't think I understand) fails me since it doesn't seem to install mysql.connector. It gives a deprecation, collects mysql.connector and launches an error.
Direct download through this site: https://dev.mysql.com/downloads/connector/python/ whereby I've changed security preferences(since it was an unidentified by apple developer) and tried downloading but the application doesn't appear anywhere on my desktop and I can't seem to find it anywhere else.
I followed this link: https://www.youtube.com/watch?v=1ji8lqiBJe0 and everything went fine till 1:34. I don't use pycharm so I decided to directly write import mysql.connector on idle.
At first, it would give me this error:-
Traceback (most recent call last):
File "", line 1, in
import mysql.connector
ModuleNotFoundError: No module named 'mysql
Now it presents this error:-
Traceback (most recent call last):
File "", line 1, in
import mysql.connector
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mysql/connector/init.py", line 41, in
import dns.resolver
ModuleNotFoundError: No module named 'dns'
I can't seem to understand where 'dns module' comes from. Could anybody help me on how to proceed? I think I've exhausted every method at this point but can't find an error.
Have you correctly install dnspython ?
pip install dnspython
https://github.com/rthalley/dnspython
and the connector for your OS
https://dev.mysql.com/downloads/connector/python/
Related
I am trying to learn how to use pymem in Python.
I have tried to make two different programs according to two tutorials I have seen but I always get the same error when I try to run the code.
I have this:
from pymem import Pymem
pm = pymem("ac_client.exe")
health = pm.read_int(0x007B43F4)
print ("Health: ", health)
But when I try to run the code I get the following error:
Traceback (most recent call last):
File "c:\Users\N\Desktop\PYTHON\pymem\pymem2.py", line 1, in <module>
from pymem import Pymem
File "c:\Users\N\Desktop\PYTHON\pymem\pymem.py", line 4, in <module>
from pymem.process import *
ModuleNotFoundError: No module named 'pymem.process'; 'pymem' is not a package
I have pymem installed in it's latest version from Visual Studio Code. And in the videos I've seen (one is from a few months ago) they have the same code as me.
You have a file named pymem.py that's mentioned in the exception message (specifically c:\Users\N\Desktop\PYTHON\pymem\pymem.py). This locally written pymem module is shadowing the pymem package you've installed elsewhere (python\python310\lib\site-packages according to one of your comments, though that path is not complete).
You need to rename your pymem.py file to something else if you want to be able to use the package.
I think you don't have it installed, try going into cmd, Terminal or whatever and type pip install pymem.
pip should install the package for you and you should be good.
I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?
I downloaded this library: https://github.com/bufferapp/buffer-python
Ran the setup.py install, and then tried to run some code using the newly installed library.
What happens though is I get this error:
Traceback (most recent call last):
File "twitter-quote-bot.py", line 14, in <module>
from buffpy.managers.profiles import Profiles
ImportError: No module named managers.profiles
The only way I've found to fix it is to move my program (twitter-quote-bot) into the downloaded folder from Buffer and run it there.
Did I do something wrong in the installation? It seems like I should be able to do these imports globally.
Thanks in advance!
I've decided to give Python a try on Netbeans. The problem so far is when try to run program I know works, i.e. if I ran it through the terminal. For the project I selected the correct Python version (2.6.5). And received the following error:
Traceback (most recent call last): File
"/Users/XXX/NetBeansProjects/NewPythonProject3/src/newpythonproject3.py",
line 4, in
import sqlite3 ImportError: No module named sqlite3
Search for PYTHONPATH. You probably have different settings in your OS and Netbeans.
I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?