I've been having trouble installing the Python API on my Mac. I first tried inside an Anaconda environment.

The initial problem seems to be related to this bug in Anaconda: https://github.com/conda/conda/issues/721 and can be circumvented by installing lxml with `conda` before attempting to install the API software. Then, installing with:

pip install csd-python-api-0.7.0-linux-py2.7.tar.gz

compiles and installs the files but seems to link them against the wrong libraries somewhere (presumably the system python and not my Anaconda python) because when I run the tests I get:

Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6 with Python 2.7.5

I can get an installation using the system Python (though not from within a virtualenv) which runs the tests, but these then fail in various ways, either by skipping the tests or with the curious error:

RuntimeError: Welcome to the CSD Python API. Access is available to all organisations and institutions.
To find details for your company or university please contact admin@ccdc.cam.ac.uk.

 

I'm following the instructions at https://downloads.ccdc.cam.ac.uk/documentation/API/installation_notes.html

Has anyone managed to get the API installed on a Mac, preferably inside a virtualenv and preferably within Anaconda?

Thanks,

Christian

Hi Christian,

 

Most of our testing on Mac OS X has been with a standard installation of Python 2.7.10. We have done some testing with Anaconda, but this has been on Linux and Windows systems.

 

We're currently having a look at use of the CSD Python API on Mac OS X with Anaconda to see if we can determine what your difficulties may be.

 

Regards,

 

Dave

Hi Christian,

 

We do most of our development inside virtualenvs, so they should work without issue.  Your use of Python 2.7.5 is fine, we fully support that.  It was quite easy to reproduce your error report - we clearly have a problem with Anaconda on OS X.

It seems that this problem is common in Anaconda. There are various workarounds proposed on the web, but we will endeavour to update the installer to overcome this. Your suggestion that this is a linking problem is correct.

Your other errors (RuntimeError: Welcome to the CSD Python API...) are a result of the API not finding a valid CSD license. Assuming that you have the CSDS installed and working, you need to ensure that the CSDHOME envvar points at the correct location. e.g.:

$ export CSDHOME=/home/my/software/csds_v536/

 

Regards,

Stewart.

 

Hi Stewart,

Thanks for your reply - I'll try to make my installation using the system Python work, then. I think I have CSDS installed correctly (I can use ConQuest and Mercury and so on): it seems to have placed its files in /Applications/CCDC/CSD_System_2015/ so accordingly I set $CSDHOME to /Applications/CCDC/CSD_System_2015/DATA/CSD_536/

Do I have the correct version of CSDS installed?
Christian

Hi Christian,

 

CSDHOME needs to point to the installation directory of the CSD System as a whole, not the data. So that would be:

 

export CSDHOME=/Applications/CCDC/CSD_System_2015

 

Regards,

 

Dave

Thanks, Dave-- I see what went wrong with this now and I have the API working with my system Python. Perhaps a comment in the Mac documentation about this path would help other Mac users?
Best wishes,

Christian

Hello--

 

I am having the same problem:

Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

 

Except I have installed standard python (2.7.10) locally and left the system python in place.  So it seems that another library is causing me the difficulties.  I am on OSX 10.9.5 and GCC 4.9.1.  This is the procedure I followed:

For Python:

./configure --disable-framework --disable-toolbox-glue --prefix=/Users/woodg07/software/python-2.7.10/ OPT="-arch x86_64 -Wall -Wstrict-prototypes -fno-common -fPIC" --enable-unicode=ucs4 LDFLAGS="-arch x86_64" --with-ensurepip=yes

make 

make install

Changed ~/.bashrc:

export PATH=/Users/woodg07/software/python-2.7.10/bin/:$PATH

export LD_LIBRARY_PATH=/Users/woodg07/software/python-2.7.10/lib:$LD_LIBRARY_PATH

export PYTHONHOME=/Users/woodg07/software/python-2.7.10/

source ~/.bashrc

CCDC:

pip install csd-python-api-0.7.0-linux-py2.7.tar.gz

You are using pip version 6.1.1, however version 7.1.0 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

Processing ./csd-python-api-0.7.0-mac-64-py2.7.tar.gz

Collecting lxml<4,>=3.3 (from ccdc==0.7.0)

  Downloading lxml-3.4.4.tar.gz (3.5MB)

    100% |████████████████████████████████| 3.5MB 130kB/s

Collecting numpy<2,>=1.9 (from ccdc==0.7.0)

  Downloading numpy-1.9.2.tar.gz (4.0MB)

    100% |████████████████████████████████| 4.0MB 110kB/s

Collecting Pillow<3,>=2.8 (from ccdc==0.7.0)

  Downloading Pillow-2.9.0.tar.gz (9.3MB)

    100% |████████████████████████████████| 9.3MB 44kB/s

Collecting six<2,>=1.9 (from ccdc==0.7.0)

  Downloading six-1.9.0-py2.py3-none-any.whl

Installing collected packages: lxml, numpy, Pillow, six, ccdc

  Running setup.py install for lxml

  Running setup.py install for numpy

  Running setup.py install for Pillow

  Running setup.py install for ccdc

 

Changed ~/.bashrc:

 

export CCDC_ISOSTAR_DATA_DIRECTORY='/Applications/CCDC//CSD_System_2015/DATA/isostar_files'

export CSDHOME='/Applications/CCDC//CSD_System_2015/'

export DYLD_LIBRARY_PATH=$PYTHONHOME/lib/python2.7/site-packages/ccdc/_lib:$DYLD_LIBRARY_PATH

export DYLD_FRAMEWORK_PATH=$PYTHONHOME/lib/python2.7/site-packages/ccdc/_lib:$DYLD_FRAMEWORK_PATH

 

 

Hi Geoffrey,

 

I suspect you are indeed running into a library mis-match similar to the one observed here:

 

http://stackoverflow.com/questions/15678153/homebrew-python-on-mac-os-x-10-8-fatal-python-error-pythreadstate-get-no-cu

 

As the stackoverflow thread discusses, it is likely that the python you have compiled, or one of the packages installed after, is linking against some of the system (Apple's) python. Note that while the CSD Python API does not build against python on your system, numpy will. What is causing the crash? If you can narrow down what import command is failing, working with the required modules first such as numpy and lxml, then otool can be used on its libraries to see what they are linking to.

 

The use of LD_LIBRARY_PATH in your second step may be the issue - you would need DYLD_LIBRARY_PATH for Mac OS X. So another potential solution is to unistall the API and its required modules and ensure that is properly set for your own python first.

 

In general, we have tended to use the ready-compiled python installer rather than building manually on the system (i.e. download the 64-bit installer from https://www.python.org/downloads/release/python-2710/). You may have more luck with that.

Thanks for the suggestions.  My next step was to narrow down which library it might be so it sounds like I was on the right path.  The problem we have here is that the company I work with has strict firewalls and poses limitations on what software can be installed so it is nearly impossible to to update system code or even install a binary version of non-approved code.  The only way around it is to have a separate environment placed in my home space...hence compiling python from source....I'll let you know how I go.

 

Cheers, Geoff.

 

Update....the problem seems to be with the ccdc modules, placing the following (below) into a file and using python to execute it gives:

CODE:

from ccdc.search import (

    TextNumericSearch

)

ERROR:

Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

 

As you say above it looks like when pip installs lxml, numpy and Pillow it might be reverting back to the old python.  Do you know if pip unlinks the User environment before it starts to compile?

 

 

 

Hello ---

 

I started to track down the various dynamic libraries that are linked to the ccdc api.  The most common system libraries I found were:

 

   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)

   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1094.0.0)

   /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)

    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

   /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)

    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0)

 

These seem to be related to c++ libraries rather than python.  I do have an updated version of gcc on my machine.  Do you think that there is a conflict in the possible different versions of gcc/g++ on my laptop that is causing the issue?

 

Thanks, Geoff.

 

 

Hi Geoff,

 

I have reproduced your issue here with a relatively standard installation of OS X, so I don't suspect it's an issue with your installed gcc/g++ libraries.

 

I have asked for some developer input on this, so please be assured that we looking into the issue, although it may take a little time before we can get back to you as there's relatively little resource in the team right now as we are in holiday season.

 

Regards,

 

Dave

I am seeing similar errors on my Mac (OS X 10.10.4, Python 2.7.10 installed via Homebrew), so any suggestions would be greatly appreciated.

Dean

Hi Dean,

 

It appears that any python distribution you are compiling yourself is having similar difficulties with what libraries are linked against. As mentioned further up in this thread we looking into this to try to determine exactly what is going on. In the meantime, if you are able to install the pre-compiled python package for OS X available from the python website then we have found this works well.

 

Dave

Dave - I can confirm that downloading the pre-compiled Python works for me - thanks! The only issue is that now I have three different copies of Python 2.7 on my system, the Apple-installed version (/usr/bin/python), the Homebrew copy (/usr/local/bin/python), and now the "official" pre-compiled version (/Library/Frameworks/Python.framework/Versions/2.7/bin/python). It would be nice to be able to run the CSD Python API using the Homebrew version since using a different Python installation can interfere with other Homebrew package installations.

FYI - this is what I put in my .bash_profile:

export CSDHOME=/Applications/CCDC/CSD_System_2015
export CCDC_TOOLKIT_SQLITE_DATABASE=/Applications/CCDC/CSD_System_2015/DATA/CSD_536/as536be_ASER.sqlite
export PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.7
export DYLD_LIBRARY_PATH=$PYTHONHOME/lib/python2.7/site-packages/ccdc/_lib
export DYLD_FRAMEWORK_PATH=$PYTHONHOME/lib/python2.7/site-packages/ccdc/_lib

Hello,

I am also having the same issue with my installation of the ccdc python package. I'm using python 2.7.10 installed with Homebrew on Mac OS X 10.9.5. Has any progress been made on this issue?

Best,

Tess

With the 1.0 release of the CSD Python API we have made an installer specifically for Anaconda Python, and this is now the recommend way to use the CSD Python API on Mac OS X. If using standard Python, we would recommend using the pre-compiled installer as provided on the Python download website.

You must be signed in to post in this forum.