I was using Big Sur with Python 3.8.2 (not Homebrew's, but native OS' Python) and I had a lot of packages installed (around 60). Now I updated my OS to Monterey 12.6 and I updated Xcode to 14.0 which updated Python to 3.9.6. And I had a very nasty surprise - all of my packages are gone. There is not a single package I installed when I was using Python 3.8.2. I sure hope it didn't delete them for good. I found some of them in ~/Library/Python/3.8 but not all. If I knew this would happen, I would use pip freeze. How can I fix this?
To answer my own question. For some reason update of Xcode decides to update Python also. So beware when you are updating it, you packages are still there, but for older version which will become unavailable.
In my case, after update Xcode my project on Python do not connecting to mysql database with error MySQLdb.OperationalError: (2002, "Can't connect to server on 'xxx.xxx.xxx.xxx' (60)"). In this time Dbeaver still connecting and work perfect
I have installed python 3.5.3 installed on my Windows machine. I check the SQLite version via the command sqlite3.sqlite_version. It is version 3.8.11.
My question is how can I update the SQLite version to 3.26? I wasn't sure if there was a 3rd party library or if I need to update sqlite3 library.
Thanks.
Just update the sqlite in the system by a newer version. Python will use it. It is not 3rd party. It is included in Python. I am not completely sure but I think it is a dynamically loaded library installed with Python but that you can upgrade by yourself. At least in my system different Python versions report the same sqlite3 version.
I'm using pycharm for the current project.
When using the sqlite console under pycharm it shows that it has the version 3.25.1, which means that the sqlite upsert works perfectly. But on python, when I do import sqlite3 it imports the version 3.20.1 of it.
I don't know why that difference in versions and I want to import the latest version of sqlite in python to be able to work with upserts.
Edit: I'm using Fedora 27 and python 3.7.0
You can choose the version of packages when selecting in pycharm Settings > Project Interepter > and upgrade the packages you want, here's a link to an old question, however, there are some recent answers, hope it what you want Link to an old question
It seems that sqlite 3.24+ requires Fedora 29+.
I just upgraded my fedora to version 29 and I got sqlite 3.24.0
I'm badly confused. I have very little problem with the Python language, but setting up Python seems to be beyond me.
I have a Windows 7 machine. I have installed the 64-bit version of Python 3.6 (more about why 64 bits later). I need the pyodbc module. I also have the 32-bit version of Python 3.5, and pyodbc is installed in its site-packages folder. The first time I tried to get pyodbc for 3.6, pip told me the requirement was already fulfilled by the version in 3.5. Then, I found the --ignore-installed option and successfully (?) installed it in my 3.6 folder.
When I open my project in PyCharm and select my 64-bit Python 3.6 as the interpreter, PyCharm shows me the pyodbc package. But when I open the file in which pyodbc is imported, PyCharm highlights the import line and tells me it can't find pyodbc. Just in case PyCharm was confused, I tried running my program from a command window, and got the same error.
Do I have to set an environment variable? I didn't have one set when I used pyodbc in a project using Python 3.5, and I had no problem.
I am trying to use 64-bit Python because a customer requires us to write into their Oracle database. They installed an ODBC driver for us, into their standard DSN list. But since we installed a 32-bit version of Python on their system, the only DSNs it can see are those installed in the 32-bit list of DSNs. If there is some easy way to use the 64-bit Oracle ODBC driver from 32-bit Python, I'd appreciate learning about it.
Thanks again.
I am finding it difficult to use MySQL with Python in my windows system.
I am currently using Python 2.6. I have tried to compile MySQL-python-1.2.3b1 (which is supposed to work for Python 2.6 ?) source code using the provided setup scripts. The setup script runs and it doesn't report any error but it doesn't generate _mysql module.
I have also tried setting up MySQL for Python 2.5 with out success. The problem with using 2.5 is that Python 2.5 is compiled with visual studio 2003 (I installed it using the provided binaries). I have visual studio 2005 on my windows system. Hence setuptools fails to generate _mysql module.
Any help ?
Download page for python-mysqldb. The page includes binaries for 32 and 64 bit versions of for Python 2.5, 2.6 and 2.7.
There's also discussion on getting rid of the deprecation warning.
UPDATE: This is an old answer. Currently, I would recommend using PyMySQL. It's pure python, so it supports all OSes equally, it's almost a drop-in replacement for mysqldb, and it also works with python 3. The best way to install it is using pip. You can install it from here (more instructions here), and then run:
pip install pymysql
This may read like your grandpa givin advice, but all answers here did not mention the best way: go nd install ActivePython instead of python.org windows binaries. I was really wondering for a long time why Python development on windows was such a pita - until I installed activestate python. I am not affiliated with them. It is just the plain truth. Write it on every wall: Python development on Windows = ActiveState!
you then just pypm install mysql-python and everything works smoothly. no compile orgy. no strange errors. no terror. Just start coding and doing real work after five minutes.
This is the only way to go on windows. Really.
As Python newbie learning the Python ecosystem I've just completed this.
Install setuptools instructions
Install MySQL 5.1. Download the 97.6MB MSI from here You can't use the essentials version because it doesnt contain the C libraries.
Be sure to select a custom install, and mark the development tools / libraries for installation as that is not done by default. This is needed to get the C header files.
You can verify you have done this correctly by looking in your install directory for a folder named "include". E.G C:\Program Files\MySQL\MySQL Server 5.1\include. It should have a whole bunch of .h files.
Install Microsoft Visual Studio C++ Express 2008 from here This is needed to get a C compiler.
Open up a command line as administrator (right click on the Cmd shortcut and then "run as administrator". Be sure to open a fresh window after you have installed those things or your path won't be updated and the install will still fail.
From the command prompt:
easy_install -b C:\temp\sometempdir mysql-python
That will fail - which is OK.
Now open site.cfg in your temp directory C:\temp\sometempdir and edit the "registry_key" setting to:
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
now CD into your temp dir and:
python setup.py clean
python setup.py install
You should be ready to rock!
Here is a super simple script to start off learning the Python DB API for you - if you need it.
I found a location were one person had successfully built mysql for python2.6, sharing the link, http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
...you might see a warning while import MySQLdb which is fine and that won’t hurt anything,
C:\Python26\lib\site-packages\MySQLdb__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
What about pymysql? It's pure Python, and I've used it on Windows with considerable success, bypassing the difficulties of compiling and installing mysql-python.
You're not the only person having problems with Python 2.6 and MySQL (http://blog.contriving.net/2009/03/04/using-python-26-mysql-on-windows-is-nearly-impossible/). Here's an explanation how it should run under Python 2.5 http://i.justrealized.com/2008/04/08/how-to-install-python-and-django-in-windows-vista/
Good luck
The precompiled binaries on http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python is just worked for me.
Open MySQL_python-1.2.5-cp27-none-win_amd64.whl file with zip
extractor program.
Copy the contents to
C:\Python27\Lib\site-packages\
On Python 3.4 I've installed mysqlclient from http://www.lfd.uci.edu/~gohlke/pythonlibs/ with pip install mysqlclient and it's working.
You can try to use myPySQL. It's really easy to use; no compilation for windows, and even if you need to compile it for any reason, you only need Python and Visual C installed (not mysql).
http://code.google.com/p/mypysql/
Good luck
There are Windows binaries for MySQL-Python (2.4 & 2.5) available on Sourceforge. Have you tried those?
Because I am running python in a (pylons/pyramid) virtualenv, I could not run the binary installers (helpfully) linked to previously.
I had problems following the steps with Willie's answer, but I determined that the problem is (probably) that I am running windows 7 x64 install, which puts the registry key for mysql in a slightly different location, specifically in my case (note: I am running version 5.5) in: "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.5".
HOWEVER, "HKEY_LOCAL_MACHINE\" cannot be included in the path or it will fail.
Also, I had to do a restart between steps 3 and 4.
After working through all of this, IMO it would have been smarter to run the entire python dev environment from cygwin.
If you are looking for Python 3.2 this seems the best solution I found so far
for Python 2.4 - 3.2 PyMySQL
for Python 2.3 - 2.6 MySQL for Python
Source: http://wiki.python.org/moin/MySQL
You might want to also consider making use of Cygwin, it has mysql python libraries in the repository.
You can also use pyodbc with the MySQL Connector/ODBC to use MySQL on Windows. Unixodbc is also available to make the code compatible on Linux. Pyodbc uses the standard Python DB API 2.0 so if you stick with that switching between MySQL/PostgreSQL/SQLite/ODBC/JDBC drivers etc. should be relatively painless.
upvoted itsadok's answer because it led me to the installation for python 2.7 as well, which is located here: http://www.codegood.com/archives/129
Got sick of the installation troubles with MySQLdb and tried pymysql instead.
Easy setup;
git clone https://github.com/petehunt/PyMySQL.git
python setup.py install
And APIs are pretty much the same.