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.
Related
I have installed SQL Server 2017 with Python but it came with Python 3.5.2 and Anaconda 4.2.0. Is there a way to upgrade the Python to 3.7?
This is the only official document I found and tried
https://learn.microsoft.com/en-us/sql/advanced-analytics/r/use-sqlbindr-exe-to-upgrade-an-instance-of-sql-server?view=sql-server-2017 but even this installed 3.5
Please help.
Thanks,
Avinash
It may be easiest to open https://www.python.org/downloads/ and install the latest release. If you have Visual Studio 2017/2019, open the solution explorer, open your python project (or import a new one into a Python Application) and point your application to this latest version. Either way, the latest version will exist on the machine. Note that some versions may be 32 bit and not 64 bit.
PyCharm Community Edition is another option.
this may help. a brief scan of it looks like there is a package created just for this purpose, dating python version and packages on SQL server machines:
https://learn.microsoft.com/en-us/sql/machine-learning/package-management/install-additional-python-packages-on-sql-server?view=sql-server-ver15
I am using pyodbc with Python 3.7. I am running an older version of SQL-Server, but it should work on your version too.
So just install Python 3.7, import pyodbc, set the "driver" specifically to a SQL Server client and you are good to go.
I have been using Python 2.7 so far on my Windows 10 machine.
Now I need to migrate towards Python3.6, but I need to run both versions in parallel for quite a while until all old scripts have been converted to Python3. From the Python3 documentation, I gather that this should be possible.
I have installed both versions, which seems to have worked, and Hello World etc. works fine on both.
Now, one of the modules I routinely work with is cx_Oracle, and even though I have installed it for Python3, it does not seem to work. (I have installed both Python and cx_Oracle from .exe installers, both are 32 bit versions, just like the old Python2.7 (under which cx_Oracle works just fine).
import cx_Oracle
gives me
ImportError: DLL load failed: Procedure not found
I have adjusted PATH to contain both Python27 and Python3, and I have rebooted.
Can anyone tell me how to solve this? Does the Python3 version need its own Oracle Instant Client or something?
Edit:
I have installed cx_Oracle cx_Oracle-6.0b1-cp36-cp36m-win32 using pip, without errors, and rebooted again.
Now cx_Oracle works from within Eclipse PyDev but when I call the same script from IDLE, I get ''ModuleNotFoundError: No module named 'cx_Oracle''' ???
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.
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
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