Python Forum
Pymssql library failing when upgrading to Python 3.7 - win32 issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pymssql library failing when upgrading to Python 3.7 - win32 issue
#1
Hi,

I upgraded Python from 3.4 to 3.7 and now when I test my code I get the error

File "J:\Python_Scripts\Python_Application_Testing_Briars\BriarsNurseryApp.pyw", line 13, in <module>
import pymssql #http://pymssql.org/en/stable/
File "src\_mssql.pxd", line 10, in init pymssql
ImportError: DLL load failed: %1 is not a valid Win32 application.


I've read discussions and have tried various suggestions, such as installing the pymssql wheel directly from https://www.lfd.uci.edu/~gohlke/pythonlibs/ and uninstalling/upgrading pip, Python and pymssql but nothing works.
My machine is 64bit so I installed the Windows x86-64 web-based installer version of Python. I did try the 32bit version but other errors appeared.
There doesn't appear to be a win32 version of pymssql so it fails. Has anyone else had this problem specificially with pymssql and Python 3.7? I also read the error could be misleading.

Thanks Wall
Reply
#2
Packages need to be installed for each version of python.
This can usually be done using 'pip' if you chose to update environment variables when installing python 3.7.
To check that all is in sync:
python -V
pip -V
You should see something like:
Output:
$ python -V Python 3.7.3 $ pip -V pip 19.1.1 from /home/.../.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip (python 3.7)
locations will varyy depending on your environment, but should match as far as version number, and should be 3.7...
if not, python was not installed properly, please follow https://python-forum.io/Thread-Part-1-Py...er-Windows

If all is well, you can re-install pymssql with:
pip install pymssql
My guess is that the environment variable update was not chosen.
Reply
#3
Hi Larz60+. Thanks for that but I see "requirement already up-to-date". I have the latest version of pymssql.
Hmmm. Perhaps I need to use one of the other sql modules instead.

Ok, I uninstalled Python and pip, and completely removed the Python folder, then reinstalled using the advanced settings which puts Python in a different location (C:\Program Files) and now it all works. The only difference so far is that I need admin permissions to pip install/update etc but I can live with that.

Thanks for your help anyway.

Regards,
Reply
#4
(Jun-22-2019, 09:28 AM)stixmagiggins Wrote: ImportError: DLL load failed: %1 is not a valid Win32 application.
This is error message is almost always a mix up 32-bit and 64-bit.
(Jun-22-2019, 09:28 AM)stixmagiggins Wrote: There doesn't appear to be a win32 version of pymssql so it fails.
No this is just wrong.

Type python in cmd.
This is what matter [MSC v.1916 32 bit (Intel)] or look like this [MSC v.1915 64 bit (AMD64)].
This is Python version 32-bit and 64-bit.
If i test on 32-bit Python version.
E:\div_code
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

E:\div_code
λ pip -V
pip 19.1.1 from c:\python37\lib\site-packages\pip (python 3.7)

E:\div_code
λ pip install pymssql
Collecting pymssql
  Downloading .... pymssql-2.1.4-cp37-cp37m-win32.whl (353kB)
Installing collected packages: pymssql
Successfully installed pymssql-2.1.4
You see that it find correct wheel pymssql-2.1.4-cp37-cp37m-win32.whl
This mean that wheel if for Python 3.7 and 32-bit version of Python
If i test it will work.
>>> import pymssql
>>> pymssql.VERSION
(2, 1, 4)

>>> exit() 
So it should detected correct version,on Gohlke pymssql
The 64-bit version is pymssql‑2.1.4‑cp37‑cp37m‑win_amd64.whl.

If i download with my Anaconda Python version which is 64-bit.
You see that it download wheel i marked over.
G:\Anaconda3\Scripts
λ pip install pymssql
Collecting pymssql
  Downloading .... pymssql-2.1.4-cp37-cp37m-win_amd64.whl (411kB)

Installing collected packages: pymssql
Successfully installed pymssql-2.1.4
Reply
#5
Thanks for the reply.

I did check those things before but installing via wheel or directly with pip didn't make a difference.
Even though Python is 64bit it is on win32. Does that affect things?
Reply
#6
(Jun-24-2019, 06:17 AM)stixmagiggins Wrote: Even though Python is 64bit it is on win32. Does that affect things?
No,it's the Python version of 32-bit or 64-bit that matter,most have 64-bit version of Windows these days.
Look at installation tutorial make sure you make new folder Path as shown there so you get all new files.
So no files get mixed up.

It should auto detect 32 or 64 bit when do pip install pymssql.
Can do it manually download pip install pymssql‑2.1.4‑cp37‑cp37m‑win_amd64.whl,but should not be needed.
So this is the 64-bit wheel,so i use a Python 64-bit version.
G:\Anaconda3
λ python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
[MSC v.1915 64 bit (AMD64)] the version on Python.
G:\Anaconda3\Scripts
# Manually wheel install 
λ pip install pymssql-2.1.4-cp37-cp37m-win_amd64.whl
Processing g:\anaconda3\scripts\pymssql-2.1.4-cp37-cp37m-win_amd64.whl
Installing collected packages: pymssql
Successfully installed pymssql-2.1.4
No error it work.
G:\Anaconda3
λ python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
>>> import pymssql
>>> pymssql.VERSION
(2, 1, 4)
>>>
>>> exit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Failing regex, space before and after the "match" tester_V 6 1,115 Mar-06-2023, 03:03 PM
Last Post: deanhystad
  Failing to print sorted files tester_V 4 1,188 Nov-12-2022, 06:49 PM
Last Post: tester_V
  Failing reading a file and cannot exit it... tester_V 8 1,753 Aug-19-2022, 10:27 PM
Last Post: tester_V
  Failing regex tester_V 3 1,143 Aug-16-2022, 03:53 PM
Last Post: deanhystad
  Upgrading from 2 to 3 and having file write problems KenHorse 2 1,430 May-08-2022, 09:47 PM
Last Post: KenHorse
  Python library for win32 console commands eldiener 3 3,384 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Win32\ping.exe windows pops up -very annoying... tester_V 9 3,126 Aug-12-2021, 06:54 AM
Last Post: tester_V
  Failing to connect to a host with WMI tester_V 6 4,278 Aug-10-2021, 06:25 PM
Last Post: tester_V
  Failing to get Stat for a Directory tester_V 11 3,475 Jul-20-2021, 10:59 PM
Last Post: Larz60+
  Issue with a library ebolisa 2 1,711 Feb-27-2021, 08:35 AM
Last Post: ebolisa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020