I've looked at other similar issues, but all my paths seem to be fine. I tried to install the python mysql library in conda so I could use it. To all metrics, it seems installed and recognized in the Pycharm interpreter, and when running conda list, I see mysql as an installed library, yet any time I try to import it, I get a ModuleNotFoundError. See below for a sample:
To isolate the issue, I chose to install another well known package that was not previously on my env, tenserflow, here's the results of that:
Evidently the issue is with the mysql library, since tensorflow installed and functioned as expected, meaning this isn't an issue with the interpreter, or an incorrect python path, or probably even conda.
I'm at a loss to what the issue is. I have mysql server installed, though that shouldn't matter, and I only have one environment. I'm trying to connect to a db, and have never used any mysql libraries on Python, so if there's others can be recommended, I have no preference, I just want my db!
Thanks in advance!
You have only installed the c library mysql, not the python library that you were looking for.
You need to do
conda install -c conda-forge mysql-connector-python
which will install the mysql python module that you are looking for
Related
I'm trying to install ibm-db into a virtual environment with Python running on an IBM i. I'm running into the following exception about limits.h no such file or directory. All the other similar questions I've found were either on Linux or MacOS, so not sure how to resolve this on an IBM i.
I also tried doing this at the system level without a virtual environment and ran into the same problem. I'm trying to install ibm-db version 3.0.2 (latest at time of this question) and that could be part of the problem. If I list the system installed packages, there is a version 2.0.5.12 of ibm-db already installed.
My IBM i is at release V7R2.
Update 2021-01-15 # 1:42PM
This seems to not be limited to the latest version of ibm-db. I tried installing a few other versions, right down to 2.0.5 and I get the same error. So it sounds like something is missing in the environment.
Despite a few mentions of IBM i (or i5) in the main ibm-db project, it really doesn't have proper support for being run from IBM i. (It may be the case that connecting to IBM i from some other platform still works; I have not verified this.) If you want to use ibm-db with IBM's Python for PASE, you need to be using Kevin Adler's fork. See the issue establishing this.
The most straightforward way to do this is via the RPMs (installed via yum directly, or the Access Client Solutions GUI). It looks like you already have the latest version of this installed (2.0.5.12 as of this writing).
Further, if you want to use virtual environments (which is a good idea), your best bet is to use the --system-site-packages option, so that it finds the RPM-installed one.
Finally, if you are not tied to ibm-db, the recommended way to connect in a PEP-249-ish way is through ODBC. There is now sufficient support for ODBC on PASE that you can actually develop and test code connecting from your PC to IBM i using pyodbc, and then just use that exact same code on PASE.
I have MySQL and Python on my computer. I want to write statements in Python scripts that extract (SELECT) data from a MySQL schema and other statements that INSERT data into MySQL tables.
My version of Python is 2.7, and I installed it via Anaconda.
From what I have read it would be appropriate to use the module “import MySQLdb”. But before doing so, I would need to download and install some code that supports this module. The only code that I have found that might work are mysql-connector-python-2.1.5-py2.7-winx64.msi or mysql-connector-python-2.1.5-py2.7-win32.msi.
When I execute either of those MSI’s, the result is a pop-up with an error message: “Python 2.7 not found. We only support Python installed using the Microsoft Windows Installer (MSI) downloaded from http://www.python.org/download/. Please check the Connector/Python manual on http://dev.mysql.com/doc/ for more information."
I skimmed the Connector/Python manual to find more information about the incompatibility; no luck. I checked the PATH on my computer; it does include c:\users\sncole\Anaconda, and python.exe does reside in this folder.
Is there any way that I can use one of the MSI’s mentioned above, or is there another download that I can use for Python that was installed via Anaconda?
Assuming that you have installed Anaconda correctly, conda should be in your path. Then you can install mysql connector by typing
conda install -c anaconda mysql-connector-python
My various searches seem to come up with very old posts or a mention of how to do this under cygwin. I had python 3.5 installed and then installed Anaconda3. I have python 3.5 (Cpython) installed in my user directory. I tried changing the order of how things appear in my Windows Environment Variables path, so that I could try both the Anaconda version of Python and the other version of python that I have.
Currently, I am a bit confused as to the package name that I should use. Is it python-mysqldb, or MySQLdb, or mysqldb, mysqlclient. I believe that when I had Anaconda3 in my global path (and the other version of python in my user path), I was able to install mysqlclient.
Initially, I am just trying to follow a tutorial from a training site that covers databases and uses peewee.
So, can the mysql driver for peewee be installed for python3? Or on Windows specifically?
It is easy enough to use sqlite3, one doesn't use that in production, is that right?
Can someone help me? Provide some guidance?
Also, one source of confusion is when other forms of installation of a python package are listed in the google results (many point to stack overflow), such as using easy_install, or cloning something from git. When I see instructions that are from 2010 and they reference easy_install, I had been thinking that now we can just use pip instead? Also, sometimes I see use of the conda command. Does that work the same as pip?
Thanks in advance,
Bruce
You could use pymysql. "The goal of PyMySQL is to be a drop-in replacement for MySQLdb". Check the docs here. Install the following libraries
pip install mysqlclient pymysql
Once these libraries are installed, just add the lines in the manage.py file in your project and use the database settings for mysql.
import pymysql
pymysql.install_as_MySQLdb()
Now any files that import MySQLdb will work.
I downloaded Snappy library sources for working with compression and everything was great on one machine, but it didn't work on another machine. They have completely same configurations of hardware/OS + python 2.7.3.
All I was doing is "./configure && make && make install".
There were 0 errors during any of these processes and it installed successfully to the default lib directory, but python cant see it anyhow. help('modules') and pip freeze doesn't show snappy on the second machine and as the result I cant import it.
I tried even 'to break' structure and install it to different lib catalogs, but even that didn't work. I don't think if its related to system environment variables, since python should have completely same configuration on any of these machines (Amazon EC2).
Anyone knows how to fix this issue?
I just found python-snappy on github and installed it via python. Not a permanent solution, but at least something.
I'm calling on psycopg2 with
import psycopg2
I get the std error
ImportError: No module named psycopg2
I installed my copy with macports, so I'm curious why it wouldn't work because all of the dependencies should be downloaded as well.
I don't have any experience with Postgresql, nor this module, so I don't know what could be going wrong. Fact is, another project I'm trying to get built calls upon it, so if I could avoid using this I would. :)
I'm sure that postgresql is installed, but that has little to do with the fact that my installation can't find psycopg2. Any suggestinos would be appreciated.
$ which python
reveals
/Library/Frameworks/Python.framework/Versions/Current/bin/python
and
$ python --version
reveals
Python 2.7.3 -- EPD_free 7.3-2 (32-bit)
I don't necessarily want the version of EPD_free, but I had to install it for (somewhat) unrelated reasons.
MacPorts installs its own version of Python alongside Apple's version. You can manage the active version of Python (the one that gets run when you type in python at the command line or by /usr/bin/env) by using the port select command. See this question.