Short version of the question: How can I get pip to install pyodbc in my Python 3.6 folder instead of seeing that it already exists in my 3.5 folder?
Because we have customers with various versions of Python, I have various versions on my computer. Also, we have been using the ancient adodb provider via COM, and using the win32com package to talk to it. Therefore, we have been using 32-bit versions of Python.
A new customer requires that we write to their Oracle database. They installed an Oracle ODBC driver in their server. However, it's a 64-bit ODBC driver, and when we run 32-bit Python, the driver will not be found.
A couple of years ago, I wrote a set of database wrapper classes based on adodb (and therefore on win32com) to meet our specific needs. I recently learned about pyodbc, and rewrote those classes to use pyodbc and remove reliance on adodb and win32com.
For this customer, I would like to use my new pyodbc classes. I tried to use pip to install pyodbc in my Python 3.6 installation, but it told me that the requirement is already satisfied because I have pyodbc in my Python 3.5 installation. I can copy it into 3.6, but I'd like to be able to use pip. What do I need to do?
Thank you.
Related
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 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
I am writing Python3 and we have a database(mssql).
I have some strings and want to put these strings into db table. But I could not handle connecting to DB. Some people suggested using pyodbc but my python version is 3.4.4 and pyodbc is not supporting it. I am writing my codes in PyCharm IDE and I am not using anyother IDE such as Visual Studio, Eclipse, etc. DB is created and the table exists.
Which programs or libraries do I need?
Which lines that I should write to code (like import pypmssql)
Language: Python3 version 3.4.4
IDE: PyCharm latest version
DB: MSSQL
If you work on a Linux distribution, try to install pip3 (python dependency manager for python 3) then run
pip install pymssql
Then read the library documention to learn how to use it at http://pymssql.org/en/latest/
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.
pyodbc is a very nice thing, but the Windows installers only work with their very specific python version. With the release of Python 3.4, the only available installers just stop once they don't see 3.3 in the registry (though 3.4 is certainly there).
Copying the .pyd and .egg-info files from a 3.3 installation into the 3.4 site-packages directory doesn't seem to do the trick. When importing pyodbc, an ImportError is thrown: ImportError: DLL load failed: %1 is not a valid Win32 application.
Is there a secret sauce that can be added to make the 3.3 file work correctly? Or do we just need to wait for a 3.4 installer version?
The different versions of Python are (for the most part) not binary-compatible, and thus any compiled extensions (such as pyodbc) will only work for a specific version.
Note that pure-Python packages (the ones that are completely written in Python, and have no non-Python dependencies) do not need to be compiled, and thus can be written to support multiple Python versions.
Also note that it is technically possible for a compiled extension to be written such that it works for Python 3.2 as well as 3.3, 3.4, and the future 3.x's to come, but they have to limit themselves to the "stable ABI" as specified by PEP 384, and most extensions do not do this. As far as I know, pyodbc is not limited to the stable ABI and must be compiled separately for each Python version.
That said, it is also possible to compile your own version of pyodbc from source, as long as you have the required tools and expertise. (But I'm guessing if you're asking this question, you don't. I don't either, otherwise I'd include some tips in this answer.)
As you have already commented, pypyodbc may be your best bet, as it is a pure-Python package.
Installing pypyodbc can be done via the commandline:
C:\Python34\Scripts>pip install pypyodbc
Using it as drop-in replacement of pyodbc can be done using:
import pypyodbc as pyodbc
[The current version of pyodbc at the time of this edit is 3.0.10, and it does support Python 3.4. Of course, it's still useful to be aware of pypyodbc in case pyodbc falls behind again when future versions of Python are released.]
Did you try to download from here? It has an unofficial build for 3.4. I did a quick test myself, looks like it's working fine for me.
I fixed this by installing pyodbc 3.0.10. The latest version of pyodbc didn't work on Windows with Python 3.4
However pyodbc 3.0.10 did work for me
Install command on command prompt : pip install pyodbc 3.0.10