Ubuntu 中的 Zipline - 安装错误

Zipline in Ubuntu - Install error

所以我正在尝试安装 zipline,但出现了一个我不知道如何处理的错误。首先我 运行 以下命令:

virtualenv -p python3.5 zipline
source /zipline/bin/activate

然后按照指南的建议

sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev

这会顺利安装,然后

pip install numpy
pip install cython
pip install -U setuptools

然后最后

pip install zipline

这给出了以下(长)错误消息,尽管我看起来多次出现相同的错误。

zipline/assets/_assets.c:4:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
        ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for zipline
  Running setup.py clean for zipline
  Running setup.py bdist_wheel for cyordereddict ... error
  Complete output from command /home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/cyordereddict/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 /tmp/pip-wheel-dsh6t2sb --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/cyordereddict
  copying python3/cyordereddict/_version.py -> build/lib.linux-x86_64-3.5/cyordereddict
  copying python3/cyordereddict/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict
  creating build/lib.linux-x86_64-3.5/cyordereddict/benchmark
  copying python3/cyordereddict/benchmark/magic_timeit.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
  copying python3/cyordereddict/benchmark/benchmark.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
  copying python3/cyordereddict/benchmark/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
  creating build/lib.linux-x86_64-3.5/cyordereddict/test
  copying python3/cyordereddict/test/test_ordereddict.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
  copying python3/cyordereddict/test/test_cyordereddict.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
  copying python3/cyordereddict/test/_mapping_tests.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
  copying python3/cyordereddict/test/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
  running build_ext
  building 'cyordereddict._cyordereddict' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/python3
  creating build/temp.linux-x86_64-3.5/python3/cyordereddict
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-FZMKe6/python3.5-3.5.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/bluehelmet/virtualenv/zipline/include/python3.5m -c python3/cyordereddict/_cyordereddict.c -o build/temp.linux-x86_64-3.5/python3/cyordereddict/_cyordereddict.o
  python3/cyordereddict/_cyordereddict.c:12:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
        ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for cyordereddict
  Running setup.py clean for cyordereddict
  Running setup.py bdist_wheel for bottleneck ... error
  Complete output from command /home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/bottleneck/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 /tmp/pip-wheel-_x73ag17 --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/bottleneck
  copying bottleneck/version.py -> build/lib.linux-x86_64-3.5/bottleneck
  copying bottleneck/__init__.py -> build/lib.linux-x86_64-3.5/bottleneck
  creating build/lib.linux-x86_64-3.5/bottleneck/slow
  copying bottleneck/slow/nonreduce.py -> build/lib.linux-x86_64-3.5/bottleneck/slow
  copying bottleneck/slow/reduce.py -> build/lib.linux-x86_64-3.5/bottleneck/slow
  copying bottleneck/slow/move.py -> build/lib.linux-x86_64-3.5/bottleneck/slow
  copying bottleneck/slow/__init__.py -> build/lib.linux-x86_64-3.5/bottleneck/slow
  copying bottleneck/slow/nonreduce_axis.py -> build/lib.linux-x86_64-3.5/bottleneck/slow
  creating build/lib.linux-x86_64-3.5/bottleneck/src
  copying bottleneck/src/template.py -> build/lib.linux-x86_64-3.5/bottleneck/src
  copying bottleneck/src/__init__.py -> build/lib.linux-x86_64-3.5/bottleneck/src
  creating build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/nonreduce_axis_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/scalar_input_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/reduce_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/list_input_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/nonreduce_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/move_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/__init__.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/input_modifcation_test.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  copying bottleneck/tests/util.py -> build/lib.linux-x86_64-3.5/bottleneck/tests
  creating build/lib.linux-x86_64-3.5/bottleneck/benchmark
  copying bottleneck/benchmark/autotimeit.py -> build/lib.linux-x86_64-3.5/bottleneck/benchmark
  copying bottleneck/benchmark/bench_detailed.py -> build/lib.linux-x86_64-3.5/bottleneck/benchmark
  copying bottleneck/benchmark/bench.py -> build/lib.linux-x86_64-3.5/bottleneck/benchmark
  copying bottleneck/benchmark/__init__.py -> build/lib.linux-x86_64-3.5/bottleneck/benchmark
  copying bottleneck/LICENSE -> build/lib.linux-x86_64-3.5/bottleneck
  running build_ext
  building 'bottleneck.reduce' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/bottleneck
  creating build/temp.linux-x86_64-3.5/bottleneck/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-FZMKe6/python3.5-3.5.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/bluehelmet/virtualenv/zipline/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/home/bluehelmet/virtualenv/zipline/include/python3.5m -c bottleneck/src/reduce.c -o build/temp.linux-x86_64-3.5/bottleneck/src/reduce.o -O2
  In file included from bottleneck/src/reduce.c:1:0:
  bottleneck/src/bottleneck.h:4:10: fatal error: Python.h: No such file or directory
   #include <Python.h>
        ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for bottleneck
  Running setup.py clean for bottleneck
  Running setup.py bdist_wheel for bcolz ... error
  Complete output from command /home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/bcolz/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 /tmp/pip-wheel-uga7q655 --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/utils.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/ctable.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/py2help.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/version.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/toplevel.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/attrs.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/chunked_eval.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/py2help_tests.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/__init__.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/arrayprint.py -> build/lib.linux-x86_64-3.5/bcolz
  copying bcolz/defaults.py -> build/lib.linux-x86_64-3.5/bcolz
  creating build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/common.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_attrs.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_ndcarray.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_queries.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_carray_objects.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/__init__.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_carray.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/test_ctable.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/tests/all.py -> build/lib.linux-x86_64-3.5/bcolz/tests
  copying bcolz/carray_ext.pxd -> build/lib.linux-x86_64-3.5/bcolz
  running build_ext
  skipping 'bcolz/carray_ext.c' Cython extension (up-to-date)
  building 'bcolz.carray_ext' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/bcolz
  creating build/temp.linux-x86_64-3.5/c-blosc
  creating build/temp.linux-x86_64-3.5/c-blosc/blosc
  creating build/temp.linux-x86_64-3.5/c-blosc/internal-complibs
  creating build/temp.linux-x86_64-3.5/c-blosc/internal-complibs/lz4-r119
  creating build/temp.linux-x86_64-3.5/c-blosc/internal-complibs/snappy-1.1.1
  creating build/temp.linux-x86_64-3.5/c-blosc/internal-complibs/zlib-1.2.8
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-FZMKe6/python3.5-3.5.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DHAVE_LZ4=1 -DHAVE_SNAPPY=1 -DHAVE_ZLIB=1 -Ibcolz -Ic-blosc/blosc -Ic-blosc/internal-complibs/zlib-1.2.8 -Ic-blosc/internal-complibs/snappy-1.1.1 -Ic-blosc/internal-complibs/lz4-r119 -I/home/bluehelmet/virtualenv/zipline/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/home/bluehelmet/virtualenv/zipline/include/python3.5m -c bcolz/carray_ext.c -o build/temp.linux-x86_64-3.5/bcolz/carray_ext.o
  bcolz/carray_ext.c:4:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
        ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for bcolz
  Running setup.py clean for bcolz
  Running setup.py bdist_wheel for lru-dict ... error
  Complete output from command /home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/lru-dict/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 /tmp/pip-wheel-5ckeqmpz --python-tag cp35:
  running bdist_wheel
  running build
  running build_ext
  building 'lru' extension
  creating build
  creating build/temp.linux-x86_64-3.5
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-FZMKe6/python3.5-3.5.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/bluehelmet/virtualenv/zipline/include/python3.5m -c lru.c -o build/temp.linux-x86_64-3.5/lru.o
  lru.c:1:10: fatal error: Python.h: No such file or directory
   #include <Python.h>
        ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for lru-dict
  Running setup.py clean for lru-dict
Failed to build zipline cyordereddict bottleneck bcolz lru-dict
Installing collected packages: cyordereddict, bottleneck, contextlib2, decorator, networkx, numexpr, bcolz, click, toolz, multipledispatch, MarkupSafe, Mako, sqlalchemy, python-editor, alembic, sortedcontainers, intervaltree, lru-dict, empyrical, tables, zipline
  Running setup.py install for cyordereddict ... error
    Complete output from command /home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/cyordereddict/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-55p6137n/install-record.txt --single-version-externally-managed --compile --install-headers /home/bluehelmet/virtualenv/zipline/include/site/python3.5/cyordereddict:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/cyordereddict
    copying python3/cyordereddict/_version.py -> build/lib.linux-x86_64-3.5/cyordereddict
    copying python3/cyordereddict/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict
    creating build/lib.linux-x86_64-3.5/cyordereddict/benchmark
    copying python3/cyordereddict/benchmark/magic_timeit.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
    copying python3/cyordereddict/benchmark/benchmark.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
    copying python3/cyordereddict/benchmark/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict/benchmark
    creating build/lib.linux-x86_64-3.5/cyordereddict/test
    copying python3/cyordereddict/test/test_ordereddict.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
    copying python3/cyordereddict/test/test_cyordereddict.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
    copying python3/cyordereddict/test/_mapping_tests.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
    copying python3/cyordereddict/test/__init__.py -> build/lib.linux-x86_64-3.5/cyordereddict/test
    running build_ext
    building 'cyordereddict._cyordereddict' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/python3
    creating build/temp.linux-x86_64-3.5/python3/cyordereddict
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-FZMKe6/python3.5-3.5.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/bluehelmet/virtualenv/zipline/include/python3.5m -c python3/cyordereddict/_cyordereddict.c -o build/temp.linux-x86_64-3.5/python3/cyordereddict/_cyordereddict.o
    python3/cyordereddict/_cyordereddict.c:12:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
          ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/home/bluehelmet/virtualenv/zipline/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-6nfwm6vn/cyordereddict/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-55p6137n/install-record.txt --single-version-externally-managed --compile --install-headers /home/bluehelmet/virtualenv/zipline/include/site/python3.5/cyordereddict" failed with error code 1 in /tmp/pip-install-6nfwm6vn/cyordereddict/

看起来造轮子有问题。谷歌了一下后,我找不到任何解决方案。你有什么意见?

所以我发现感谢我需要的评论

sudo apt install python3.5-dev

此问题已解决。