Building wheel for bcolz (setup.py): finished with status 'error' >> about zipline

164 views Asked by At

I am currently creating a Docker image, The Python version is 3.6. Below is the Dockerfile code

FROM python:3.6

WORKDIR /myfile

COPY requirements.txt /myfile/

RUN apt-get update && \
    apt-get install -y build-essential wget python-dev && \
    wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
    tar -xvzf ta-lib-0.4.0-src.tar.gz && \
    cd ta-lib/ && \
    ./configure --prefix=/usr && \
    make && \
    make install && \
    cd .. && \
    rm -rf ta-lib* && \
    fc-cache -fv && \
    rm -rf /var/lib/apt/lists/*


RUN pip install --upgrade pip && \
    pip install -r /myfile/requirements.txt


RUN mkdir -p /root/.ipython/profile_default/startup && \
    echo "import matplotlib.pyplot as plt" >> /root/.ipython/profile_default/startup/00-startup.py &&

ENTRYPOINT ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--notebook-dir=/myfile"]

The requirements are as follows cython ta-lib zipline

And my error in earnest is as follows:

265.2   Building wheel for bcolz (setup.py): started
268.7   Building wheel for bcolz (setup.py): finished with status 'error'
268.7   ERROR: Command errored out with exit status 1:
268.7    command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nwxg4ny2
268.7        cwd: /tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/
268.7   Complete output (88 lines):
268.7   SSE2 detected
268.7   AVX2 detected
268.7   running bdist_wheel
268.7   running build
268.7   running build_py
268.7   creating build
268.7   creating build/lib.linux-x86_64-3.6
268.7   creating build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/py2help_tests.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/arrayprint.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/utils.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/version.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/ctable.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/toplevel.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/attrs.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/chunked_eval.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/__init__.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/defaults.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   copying bcolz/py2help.py -> build/lib.linux-x86_64-3.6/bcolz
268.7   creating build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/all.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_ndcarray.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_ctable.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/common.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_attrs.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_carray_objects.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_queries.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/__init__.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/tests/test_carray.py -> build/lib.linux-x86_64-3.6/bcolz/tests
268.7   copying bcolz/carray_ext.pxd -> build/lib.linux-x86_64-3.6/bcolz
268.7   running build_ext
268.7   Compiling bcolz/carray_ext.pyx because it changed.
268.7   [1/1] Cythonizing bcolz/carray_ext.pyx
268.7   /tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/.eggs/Cython-3.0.6-py3.6-linux-x86_64.egg/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/bcolz/carray_ext.pxd
268.7     tree = Parsing.p_module(s, pxd, full_module_name)
268.7
268.7   Error compiling Cython file:
268.7   ------------------------------------------------------------
268.7   ...
268.7           # Create the final container and fill it
268.7           out = carray([], dtype=newdtype, cparams=self.cparams,
268.7                          expectedlen=newlen,
268.7                          rootdir=rootdir, mode='w')
268.7           if newlen < ilen:
268.7               rsize = isize / newlen
268.7                             ^
268.7   ------------------------------------------------------------
268.7
268.7   bcolz/carray_ext.pyx:1685:26: Cannot assign type 'double' to 'npy_intp'
268.7   Traceback (most recent call last):
268.7     File "<string>", line 1, in <module>
268.7     File "/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/setup.py", line 234, in <module>
268.7       cmdclass=LazyCommandClass(),
268.7     File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
268.7       return distutils.core.setup(**attrs)
268.7     File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
268.7       dist.run_commands()
268.7     File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
268.7       self.run_command(cmd)
268.7     File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
268.7       cmd_obj.run()
268.7     File "/usr/local/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 299, in run
268.7       self.run_command('build')
268.7     File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
268.7       self.distribution.run_command(command)
268.7     File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
268.7       cmd_obj.run()
268.7     File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
268.7       self.run_command(cmd_name)
268.7     File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
268.7       self.distribution.run_command(command)
268.7     File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
268.7       cmd_obj.run()
268.7     File "/usr/local/lib/python3.6/distutils/command/build_ext.py", line 339, in run
268.7       self.build_extensions()
268.7     File "/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/setup.py", line 77, in build_extensions
268.7       cython_build_ext.build_extensions(self)
268.7     File "/usr/local/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
268.7       self._build_extensions_serial()
268.7     File "/usr/local/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
268.7       self.build_extension(ext)
268.7     File "/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/.eggs/Cython-3.0.6-py3.6-linux-x86_64.egg/Cython/Distutils/build_ext.py", line 131, in build_extension
268.7       ext,force=self.force, quiet=self.verbose == 0, **options
268.7     File "/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/.eggs/Cython-3.0.6-py3.6-linux-x86_64.egg/Cython/Build/Dependencies.py", line 1154, in cythonize
268.7       cythonize_one(*args)
268.7     File "/tmp/pip-install-6ksg71o4/bcolz_4f2875df14634b418d861ca7d79e8508/.eggs/Cython-3.0.6-py3.6-linux-x86_64.egg/Cython/Build/Dependencies.py", line 1321, in cythonize_one
268.7       raise CompileError(None, pyx_file)
268.7   Cython.Compiler.Errors.CompileError: bcolz/carray_ext.pyx
268.7   ----------------------------------------
268.7   Running setup.py clean for bcolz
268.7   ERROR: Failed building wheel for bcolz

Please help me, I really need zipline for backtesting

I've tried 3.5 and 3.6, which are currently compatible with zipline, but 3.9 seems to produce a completely different error, so I'm going to use 3.6, which is the latest version in the official documentation.

1

There are 1 answers

0
Andjelko Simic On

Recently I had the same issue. I resolved this by using the version of Cython bellow 0.29 and with pip installed from get-pip.py file, you can find for your version of Python on https://bootstrap.pypa.io/pip. Avoid using pip upgrade. Part of my Dockerfile:

RUN curl "https://bootstrap.pypa.io/pip/3.6/get-pip.py" -o "get-pip.py"
RUN python get-pip.py
RUN pip install opencv-python==4.5.5.62
RUN pip install cython==0.28
RUN pip install setuptools-scm numpy
RUN pip install -r requirements.txt

In requirements.txt I only have bcolz without a specific version and no zipline or something else. After this if you have an error similar to this:

blosc error: conflicting types for ‘_xgetbv’
#17 103.9     170 | _xgetbv(uint32_t xcr) {

You should use some other base image with the installation of Python.