[Python] Setting up Sybase Module from Python in Windows – FAIL 1

I have a requirement to pull some data from a Sybase database using Python (eventually this data will be transformed and then pushed to a MySQL database, but that is for another post!)

There is a “Sybase module for Python” here:
http://python-sybase.sourceforge.net/

When you click on the 'Download' button in the sidebar, and then click the Latest Release – currently python-sybase-0.40pre2.tar.gz - it takes you to:
https://sourceforge.net/projects/python-sybase/files/

Note: I'm currently working for a large Enterprise. The first link is accessible in this large Enterprise, but the second link is not! How I'll get the module into the bank is a question for later, for now let's just get it setup on my personal workstation.

From - https://sourceforge.net/projects/python-sybase/files/ - we click the green button to 'Download Latest Version' – python-sybase-0.40pre2.zip. When the file is unzipped, it reveals the setup.py file that we will use to install the module.

If you don't already have Python, you can get it from (current latest version is 3.9.6):
https://www.python.org/downloads/

Python-3.9.6.amd64.exe is straightforward to install on Windows, just double-click and follow the prompt.

To install he Python Sybase module (on Windows), using the Command Prompt, first navigate to where you have unpacked the setup.py file. Then run:

python setup.py install

Note: There are some other options (which I tried) detailed here:
http://python-sybase.sourceforge.net/install.html

~~~

Unfortunately, it was not so simple as that! I kept getting errors when running the install like:

ERROR 1:
File "C:\...\Sybase\python-sybase-0.40pre2\ez_setup.py", line 94
except pkg_resources.VersionConflict, e:

SyntaxError: invalid syntax

I was able to fix this by editing the ez_setup.py file and removing the ', e' at the end (no idea what this does). But then we get another error:

ERROR 2:
File "C:\...\Sybase\python-sybase-0.40pre2\ez_setup.py", line 188
print "Setuptools version",version,"or greater has been installed."
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Setuptools version",version,"or greater has been installed.")?

I was able to fix it using the advice given in the SyntaxError, but then we got another error:

ERROR 3:
File "C:\Users\spacecowboy\Desktop\Sybase\python-sybase-0.40pre2\ez_setup.py", line 190
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'

SyntaxError: invalid syntax

I was able to fix this (print formatting was not right) but then we got a fourth error:

ERROR 4:
File "C:\Users\spacecowboy\Desktop\Sybase\python-sybase-0.40pre2\setup.py", line 59, in {module}
if os.environ.has_key('SYBASE'):
AttributeError: '_Environ' object has no attribute 'has_key'

And it was at this stage I started thinking “Have I downloaded the wrong package  (i.e. not the Windows one)!?” or “Was it written for a different version of Python!?”

I see here -
https://sourceforge.net/projects/python-sybase/files/python-sybase/python-sybase-0.40/
- there is a:

python-sybase-0.40.win32-py2.7.exe
python-sybase-0.40.win32.zip <-- I'll try this one as I need to get the files to the large Enterprise somehow!

And the distributions were built with Python-2.7, so is the fact I'm on Python-3.9.6 causing issues!? I really need this to work on Python 3+ since that's what is used at the place I work.

Image: I'll try python-sybase-0.40.win32.zip next (it's not exactly a popular download)



Comments