New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails with FreeTDS 1.0 on OSX #432

Closed
andrewmwhite opened this Issue May 27, 2016 · 39 comments

Comments

Projects
None yet
@andrewmwhite

andrewmwhite commented May 27, 2016

Error message:

clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/var/pyenv/versions/2.7.11/include/python2.7 -c _mssql.c -o build/temp.macosx-10.11-x86_64-2.7/_mssql.o -DMSDBLIB
_mssql.c:18783:15: error: use of undeclared identifier 'DBVERSION_80'
    __pyx_r = DBVERSION_80;
              ^
1 error generated.
error: command 'clang' failed with exit status 1

Full log of failed install command

Reverting to FreeTDS 0.91 via brew unlink freetds; brew install homebrew/versions/freetds091 fixes the issue as a work-around.

@nunoh

This comment has been minimized.

nunoh commented May 30, 2016

Yep, same here. Used a very similar fix, but instead with uninstall rather than unlink.

@ramiro ramiro added the bug label May 30, 2016

@ramiro ramiro referenced this issue Jun 1, 2016

Closed

Release 2.1.3 #436

12 of 13 tasks complete
@gdelgado

This comment has been minimized.

gdelgado commented Jun 11, 2016

+1

Same issue, the first solution worked for me.

@jacobbridges

This comment has been minimized.

jacobbridges commented Jun 14, 2016

Same issue on Ubuntu. Apparently the apt sources have linked free-tds 1.0 as the current stable version so pymssql stopped working.

@ramiro

This comment has been minimized.

Contributor

ramiro commented Jun 14, 2016

Same issue on Ubuntu. Apparently the apt sources have linked free-tds 1.0 as the current stable version so pymssql stopped working.

This is strange. Ubuntu (and Debian) are stuck on FreeTDS 0.91:

There was a third party PPA with FreeTDS packages for Ubuntu which carried 0.95. IIRC it's this one:

https://launchpad.net/~jamiewillis/+archive/ubuntu/freetds?field.series_filter=trusty

What APT repos are you using in order to get 1.0?

BTW we are asking for testing/feedback on binary wheels for Linux we are publishing for the first time, which include static version of FreeTDS 0.95.x and we plan to release in the next few days as version 2.1.3 of pymssql:

https://groups.google.com/d/msg/pymssql/rMEJAaJhX1c/rSwSuejeNwAJ

@freddy77

This comment has been minimized.

freddy77 commented Jun 21, 2016

Just use DBVERSION_71. See http://www.freetds.org/userguide/choosingtdsprotocol.htm#AEN910. Also described in the NEWS file at https://github.com/FreeTDS/freetds/blob/master/NEWS.
DBVERSION_ are preprocessor macros so you can check if #ifdef DBVERSION_80.
Actually version 7.1 refers to the protocol used by mssql 2000.

@ramiro ramiro added this to the 2.2.0 milestone Jun 22, 2016

ramiro added a commit that referenced this issue Jun 22, 2016

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes #432.

@ramiro ramiro closed this in #438 Jun 23, 2016

@tsoukw

This comment has been minimized.

tsoukw commented Jul 25, 2016

yes ,it's good for me, thank you

@jonhermansen

This comment has been minimized.

jonhermansen commented Aug 6, 2016

Will we see this fix in a new PyPI release soon?

@bkanuka

This comment has been minimized.

bkanuka commented Aug 8, 2016

@jh86 until this is in PyPI, you can install from github: pip install git+https://github.com/pymssql/pymssql.git

ramiro added a commit that referenced this issue Aug 28, 2016

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes #432.
@daniloakamine

This comment has been minimized.

daniloakamine commented Oct 22, 2016

it works, but in El Capitan I had some problems.
when I tried to install freetds091 I received the error:
configure: error: cannot run C compiled programs..

I ran brew doctor and I found out that my Xcode 6.1.1 was outdated.
So in that case, you will need update your Xcode or there is a simple solution, run xcode-select --install.
After this, try install freetds091 again.

@mcescalante

This comment has been minimized.

mcescalante commented Nov 3, 2016

Because 2.2.0 still hasn't made it to PyPI as of this comment, the following command from @bkanuka still works and installed smoothly without a single error:

pip install git+https://github.com/pymssql/pymssql.git

I'd like to update that I'm seeing this same issue on RHEL 7, and someone was seeing it on Ubuntu above so it effects more than just macOS.

@wesseljt

This comment has been minimized.

wesseljt commented Dec 1, 2016

thanks!

@mideeks

This comment has been minimized.

mideeks commented Dec 13, 2016

Any chance we can get a 2.2.0/2.1.4 release soon so we can build on macOS without having to pull from git?

@ilovezfs ilovezfs referenced this issue Mar 26, 2017

Merged

freetds: fix brew audit warning #11599

4 of 4 tasks complete
@giaosudau

This comment has been minimized.

giaosudau commented Apr 10, 2017

In my case I need to do one more step brew link --force freetds@0.91 and it works perfect.

@drorata

This comment has been minimized.

drorata commented Apr 20, 2017

I work with macports. I had to do the following:

  1. Remove installed older version of freetds
  2. Checkout the macports repo git clone --single-branch https://github.com/macports/macports-ports.git
  3. Checkout an older version, where the port is with an older version of freetds. In particular: git checkout fb32c4486dab8bc03409927f0d73a8ac3e37cada
  4. Lastly, I ran sudo port install from ~/macports-ports/databases/freetds

EDIT It turns out the the file ~/macports-ports/databases/freetds/Portfile has to be placed in a directory accessible by macports. For example /tmp/.

@anilpai

This comment has been minimized.

anilpai commented Jun 2, 2017

The complete process is here.

http://gree2.github.io/python/setup/2017/04/19/python-instal-pymssql-on-mac

@jzaleski

This comment has been minimized.

jzaleski commented Jul 7, 2017

Until v2.2.0 has been blessed/released, as it is still in development, where the core issue resolved, you can use the following tag on our fork here: https://github.com/wayfair/pymssql/releases/tag/v2.1.3.0.0.1 -- it has the necessary patch to resolve the original issue.

@adriannye

This comment has been minimized.

adriannye commented Jul 12, 2017

With 2.1.3 I get the DBVERSION error.
I was previously successful pip installing the master branch but it no longer works.
Pip installing release 2.1.3.0.0.1 fails for me with the downloaded tar on MacOS Sierra with the error:

File "/usr/local/opt/pyenv/versions/3.4.3/envs/api/lib/python3.4/site-packages/setuptools/command/build_ext.py", line 46, in

    class build_ext(_build_ext):

TypeError: str() argument 2 must be str, not tuple
@jzaleski

This comment has been minimized.

jzaleski commented Jul 13, 2017

@nickmachairas could you please give me a bit more context on the issue? I think that may be unrelated.

Update: I tried to build and I was able to build a PY-3.6.1 wheel w/o issue and install it via pip on OSX Sierra

More than happy to take a look and help you work through this though!

@jzaleski

This comment has been minimized.

jzaleski commented Jul 13, 2017

@adriannye just to confirm, you're on Python 3.4.3 on Sierra? Can you give me slightly more of the stack-trace and the versions of freetds and setuptools that you're using so I can attempt to replicate the issue?

Update: I tried to build and I was able to build a PY-3.4.3 wheel w/o issue.

Regardless, I'd be glad to help you work through this.

@adriannye

This comment has been minimized.

adriannye commented Jul 17, 2017

Thanks jzaleski, yes I'm on python 3.4.3 (pyenv) on Sierra. There's a good chance the problem is related to pyenv as I just started using that, but every other package is building fine. About a month ago I successfully installed the pymssql master using py3.6 installed with brew. I have freetds 0.91 and setuptools 12.0.5.

The full traceback is here:
https://pastebin.com/4yAVVgMV

@adriannye

This comment has been minimized.

adriannye commented Jul 17, 2017

I gave up on pyenv and brew installed python3 and the latest master works with that. So the problem was definitely related to pyenv.

@jzaleski

This comment has been minimized.

jzaleski commented Jul 18, 2017

Glad to hear it @adriannye -- Please let us know if you need help w/ anything else. Good luck!

@nickmachairas

This comment has been minimized.

nickmachairas commented Jul 18, 2017

Thank you @jzaleski, it is clear then that my issue was caused by something else. Thanks again!

shadiakiki1986 pushed a commit to shadiakiki1986/pymssql that referenced this issue Aug 15, 2017

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes pymssql#432.

shadiakiki1986 pushed a commit to shadiakiki1986/pymssql that referenced this issue Aug 15, 2017

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes pymssql#432.

shadiakiki1986 pushed a commit to shadiakiki1986/pymssql that referenced this issue Aug 15, 2017

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes pymssql#432.

CrashenX added a commit to rcbops/pymssql that referenced this issue Sep 7, 2017

Drop usage of `DBVERSION_80` symbol.
It was deprecated and was finally removed in FreeTDS 1.0.

Fixes pymssql#432.
@drorata

This comment has been minimized.

drorata commented Oct 20, 2017

After upgrading to macOS High Sierra, I tried to redo the steps in my older comment but it didn't work. The sudo port install returned:

Error: Unable to execute port: Could not open file: ~/macports-ports/databases/freetds/Portfile

Any ideas?

EDIT: pip install git+https://github.com/pymssql/pymssql.git from a comment above, worked for me.

EDIT 2: Using the current HEAD (9eca0b3) I manage to install pymssql on my machine and use it (i.e. connect to an SQL Server). I also try to use it from within a Docker container. The building of the image (including the installation of pymssql is smooth. However, I am unable to connect to the server from the container. This is very strange as only the installation of pymssql is changed.

@jzaleski

This comment has been minimized.

jzaleski commented Oct 21, 2017

@drorata

This comment has been minimized.

drorata commented Oct 21, 2017

@jzaleski I don't think the problem is due to macports. Using this commit I have the expected behavior on the mac but it breaks inside the container (based on this image).

I don't think I will be able to try out non-macports based solution. I am sorry.

@drorata

This comment has been minimized.

drorata commented Oct 23, 2017

I will try to summarize the situation I am facing.

I consider two platforms:

  1. macOS where freetds version 1.00.67 is installed using macports.
  2. Docker container where freetds is installed using
    RUN apt-get update && apt-get install -y \
      freetds-dev \
      python-dev \
      build-essential \
      && apt-get clean -y \
    
    I don't know how to check what version is it... The image's base is python:3

On the other hand I consider two versions of pymssql

  1. dev as available in this commit.
  2. 2.1.3 as pointed by this commit

The problem I witness is twofold:

  1. Inside a container I can install both version, but I can connect to the server only with the installation of 2.1.3. When trying to connect using the dev installation I get the following error:

    Traceback (most recent call last):
      File "src/pymssql.pyx", line 636, in pymssql.connect
      File "src/_mssql.pyx", line 1952, in _mssql.connect
      File "src/_mssql.pyx", line 673, in _mssql.MSSQLConnection.__init__
      File "src/_mssql.pyx", line 1680, in _mssql.maybe_raise_MSSQLDatabaseException
     _mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')
    
  2. Installing on macOS: I cannot install 2.1.3. When trying pip install pymssql I get:

     Collecting pymssql
       Using cached pymssql-2.1.3.tar.gz
     Building wheels for collected packages: pymssql
       Running setup.py bdist_wheel for pymssql ... error
       Complete output from command /Users/drorata/anaconda3/envs/test-pymssql/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/6z/h5jqtwss0m13gg40vv06gs_40000gn/T/pip-build-q457zka4/pymssql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/6z/h5jqtwss0m13gg40vv06gs_40000gn/T/tmp2g3qg71tpip-wheel- --python-tag cp36:
       setup.py: platform.system() => 'Darwin'
       setup.py: platform.architecture() => ('64bit', '')
       setup.py: platform.libc_ver() => ('', '')
       setup.py: Detected Darwin/Mac OS X.
           You can install FreeTDS with Homebrew or MacPorts, or by downloading
           and compiling it yourself.
    
           Homebrew (http://brew.sh/)
           --------------------------
           brew install freetds
    
           MacPorts (http://www.macports.org/)
           -----------------------------------
           sudo port install freetds
    
       setup.py: Not using bundled FreeTDS
       setup.py: include_dirs = ['/opt/local/include', '/opt/local/include/freetds']
       setup.py: library_dirs = ['/usr/local/lib', '/opt/local/lib']
       running bdist_wheel
       running build
       running build_ext
       building '_mssql' extension
       creating build
       creating build/temp.macosx-10.7-x86_64-3.6
       gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/drorata/anaconda3/envs/test-pymssql/include -arch x86_64 -I/Users/drorata/anaconda3/envs/test-pymssql/include -arch x86_64 -I/opt/local/include -I/opt/local/include/freetds -I/Users/drorata/anaconda3/envs/test-pymssql/include/python3.6m -c _mssql.c -o build/temp.macosx-10.7-x86_64-3.6/_mssql.o -DMSDBLIB
       _mssql.c:18814:15: error: use of undeclared identifier 'DBVERSION_80'
           __pyx_r = DBVERSION_80;
    
@thongly

This comment has been minimized.

thongly commented Nov 1, 2017

I needed this

brew link --force freetds@0.91

-credit to http://gree2.github.io/

@CPlusPlus17

This comment has been minimized.

CPlusPlus17 commented Nov 16, 2017

This problem is also in fedora 27.

@jzaleski

This comment has been minimized.

jzaleski commented Nov 17, 2017

We are in the process of pulling together a 2.1.4 wheel currently it will include this fix and others.

As an aside to address an earlier comment, depending on your hardware, it can take some time (minutes) to build the C-extension. Before we dig in further, please confirm that it isn't just taking a long time to compile. Thanks!

@kparaju

This comment has been minimized.

kparaju commented Jan 24, 2018

@jzaleski any updates on 2.1.4?

@jpgimenez

This comment has been minimized.

Contributor

jpgimenez commented Jan 31, 2018

@jpgimenez jpgimenez modified the milestones: 2.2.0, 2.1.4 Jan 31, 2018

@jfahrenkrug

This comment has been minimized.

jfahrenkrug commented Mar 27, 2018

The complete steps that worked for me were:

brew unlink freetds
brew install freetds@0.91
brew link --force freetds@0.91
pip3 install pymssql

Thanks for your help!

@HongJheLi

This comment has been minimized.

HongJheLi commented May 14, 2018

I have to do ...
brew link --overwrite --force freetds@0.91

@fanghaolei

This comment has been minimized.

fanghaolei commented Jun 1, 2018

brew unlink freetds
brew install freetds@0.91
brew link --overwrite --force freetds@0.91
pip install pymssql

This worked for me. I have python 3.6

@erg

This comment has been minimized.

erg commented Jul 20, 2018

Still having this problem on macOS, none of these solutions worked anymore except this:

sudo pip3 install git+https://github.com/pymssql/pymssql.git

@AlexHagerman

This comment has been minimized.

AlexHagerman commented Jul 21, 2018

@erg can you link me to your open issue or post on the mailing list? When you say you are still having this problem are you running into the DBVERSION issue that is what this ticket was originally opened for or the sqlfront.h not found issue on ticket 124 where you cross posted?

@erg

This comment has been minimized.

erg commented Jul 21, 2018

@AlexHagerman I hit both issues that I posted on by following various suggested fixes like installing freetds@0.91. The only one that fixed my pymssql yesterday was installing from git.

I have hit this issue repeatedly over the last two years and installing pymssql is always a pain on a new system. I'd be happy to help debug it but looks like you have it figured out with the latest git version. Perhaps you could make a release so when people install pymssql from a requirements.txt file on macOS they will have the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment