TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.62k stars 1.76k forks source link

ta-lib python for Cygwin failing with the below error #94

Closed ashgen closed 8 years ago

ashgen commented 8 years ago

python -c "import talib" Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/talib/init.py", line 5, in from . import abstract ImportError: dynamic module does not define init function (initabstract)

mrjbq7 commented 8 years ago

What version of this module? Is it latest git master?

Did you compile it yourself or download a package?

What version of cython did you use to build it?

ashgen commented 8 years ago

$ cython --version Cython version 0.23.4

Please find my setup.py and the logs being created

!/usr/bin/env python

import sys import os import warnings

from distutils.dist import Distribution

display_option_names = Distribution.display_option_names + ['help', 'help-commands'] query_only = any('--' + opt in sys.argv for opt in display_option_names) or len(sys.argv) < 2 or sys.argv[1] == 'egg_info'

Use setuptools for querying the package, normal builds use distutils

if query_only: try: from setuptools import setup except ImportError: from distutils.core import setup else: from distutils.core import setup

from distutils.extension import Extension

lib_talib_name = 'ta_lib' # the underlying C library's name

platform_supported = False for prefix in ['darwin', 'linux', 'bsd','cygwin']: if prefix in sys.platform: platform_supported = True include_dirs = [ '/usr/include', '/usr/include/ta-lib', '/usr/local/include', '/opt/include', '/opt/local/include', ] if 'TA_INCLUDE_PATH' in os.environ: include_dirs.append(os.environ['TA_INCLUDE_PATH']) lib_talib_dirs = [ '/usr/lib', '/usr/local/lib', '/usr/lib64', '/usr/local/lib64', '/opt/lib', '/opt/local/lib', ] if 'TA_LIBRARY_PATH' in os.environ: lib_talib_dirs.append(os.environ['TA_LIBRARY_PATH']) break

if sys.platform == "win32": platform_supported = True lib_talib_name = 'ta_libc_cdr' include_dirs = [r"c:\ta-lib\c\include"] lib_talib_dirs = [r"c:\ta-lib\c\lib"]

Do not require numpy or cython for just querying the package

if not query_only: import numpy include_dirs.insert(0, numpy.get_include())

try: from Cython.Distutils import build_ext has_cython = True except ImportError: has_cython = False

if not platform_supported: raise NotImplementedError(sys.platform)

for lib_talib_dir in lib_talib_dirs: try: files = os.listdir(lib_talib_dir) if any(lib_talib_name in f for f in files): break except OSError: pass else: warnings.warn('Cannot find ta-lib library, installation may fail.')

cmdclass = {} if has_cython: cmdclass['build_ext'] = build_ext

ext_modules = [] for name in ['common', 'func', 'abstract']: ext = Extension( 'talib.%s' % name, [('talib/%s.pyx' if has_cython else 'talib/%s.c') % name], include_dirs = include_dirs, library_dirs = lib_talib_dirs, libraries = [lib_talib_name] ) ext_modules.append(ext)

setup( name = 'TA-Lib', version = '0.4.9', description = 'Python wrapper for TA-Lib', author = 'John Benediktsson', author_email = 'mrjbq7@gmail.com', url = 'http://github.com/mrjbq7/ta-lib', download_url = 'https://github.com/mrjbq7/ta-lib/releases', classifiers = [ "License :: OSI Approved :: BSD License", "Development Status :: 4 - Beta", "Operating System :: Unix", "Operating System :: POSIX", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Cython", "Topic :: Office/Business :: Financial", "Topic :: Scientific/Engineering :: Mathematics", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Intended Audience :: Financial and Insurance Industry", ], packages = ['talib'], ext_modules = ext_modules, cmdclass = cmdclass, requires = ['numpy'], )

I downloaded the latest git version and then installed with adding cywin in setup.py with Unix sources . It compiled with some warnings but com[piled successfully .However when I import talib it gives me the error as attached earlier. On 23 Dec 2015 8:46 pm, "John Benediktsson" notifications@github.com wrote:

What version of this module? Is it latest git master?

Did you compile it yourself or download a package?

What version of cython did you use to build it?

— Reply to this email directly or view it on GitHub https://github.com/mrjbq7/ta-lib/issues/94#issuecomment-166921861.

mrjbq7 commented 8 years ago

Hi, I'm sorry but I finally looked and realized a bad commit had messed up abstract.c. It is fixed now if you want to try and update. It didn't affect the previous released version on PyPI if you were installing from pip, but only the git master I think.

Fixed now!!

ashgen commented 8 years ago

Hi John, Thanks for the mail. I have checked the latest git version and though the python setup went fine it gave me an error while importing common. Can you please look into it. On 6 Jan 2016 12:34 am, "John Benediktsson" notifications@github.com wrote:

Hi, I'm sorry but I finally looked and realized a bad commit had messed up abstract.c. It is fixed now if you want to try and update. It didn't affect the previous released version on PyPI if you were installing from pip, but only the git master I think.

Fixed now!!

— Reply to this email directly or view it on GitHub https://github.com/mrjbq7/ta-lib/issues/94#issuecomment-169098939.