Error while running python2.7 setup.py build_ext --inplace
Dear Zipline Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
- Operating System: Mac (High Sierra) Darwin
- Python Version:
$ python --versionPython 2.7.10 - Python Bitness:
$ python -c 'import math, sys;print(int(math.log(sys.maxsize + 1, 2) + 1))': 64 - How did you install Zipline: (
pip,conda, orother (please explain)) git clone - Python packages:
$ pip freezeor$ conda list
Now that you know a little about me, let me tell you about the issue I am having:
Description of Issue
I tried to execute the following commands
$ mkvirtualenv zipline
$ ./etc/ordered_pip.sh ./etc/requirements.txt
$ pip install -r ./etc/requirements_dev.txt
$ pip install -r ./etc/requirements_blaze.txt
$ python2.7 setup.py build_ext --inplace
- What did you expect to happen?
- What happened instead?
I am getting the following error running build_ext
skipping 'zipline/assets/_assets.c' Cython extension (up-to-date)
skipping 'zipline/assets/continuous_futures.c' Cython extension (up-to-date)
cythoning zipline/lib/adjustment.pyx to zipline/lib/adjustment.c
Error compiling Cython file:
------------------------------------------------------------
...
cdef _is_bool(object value):
return isinstance(value, (bool, bool_, uint8))
cpdef choose_adjustment_type(AdjustmentKind adjustment_kind, object value):
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:59:29: 'AdjustmentKind' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef Adjustment make_adjustment_from_indices(Py_ssize_t first_row,
Py_ssize_t last_row,
Py_ssize_t first_column,
Py_ssize_t last_column,
AdjustmentKind adjustment_kind,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:109:46: 'AdjustmentKind' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
# passed by name. This is true even if cython.always_allow_keywords is
# enabled. Yay Cython.
return type_(first_row, last_row, first_column, last_column, value)
cdef type _choose_adjustment_type(AdjustmentKind adjustment_kind,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:121:34: 'AdjustmentKind' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
# enabled. Yay Cython.
return type_(first_row, last_row, first_column, last_column, value)
cdef type _choose_adjustment_type(AdjustmentKind adjustment_kind,
column_type value):
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:122:34: 'column_type' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cdef Adjustment make_adjustment_from_indices_fused(Py_ssize_t first_row,
Py_ssize_t last_row,
Py_ssize_t first_column,
Py_ssize_t last_column,
AdjustmentKind adjustment_kind,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:159:51: 'AdjustmentKind' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cdef Adjustment make_adjustment_from_indices_fused(Py_ssize_t first_row,
Py_ssize_t last_row,
Py_ssize_t first_column,
Py_ssize_t last_column,
AdjustmentKind adjustment_kind,
column_type value):
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:160:51: 'column_type' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
# passed by name. This is true even if cython.always_allow_keywords is
# enabled. Yay Cython.
return type_(first_row, last_row, first_column, last_column, value)
cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:171:34: 'DatetimeIndex_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
# enabled. Yay Cython.
return type_(first_row, last_row, first_column, last_column, value)
cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:172:34: 'Int64Index_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
return type_(first_row, last_row, first_column, last_column, value)
cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:173:34: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
Timestamp_t end_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:174:34: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
Timestamp_t end_date,
int asset_id,
AdjustmentKind adjustment_kind,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:176:34: 'AdjustmentKind' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
asset_id,
value,
)
cpdef tuple get_adjustment_locs(DatetimeIndex_t dates_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:193:32: 'DatetimeIndex_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
value,
)
cpdef tuple get_adjustment_locs(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:194:32: 'Int64Index_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
)
cpdef tuple get_adjustment_locs(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:195:32: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef tuple get_adjustment_locs(DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
Timestamp_t end_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:196:32: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
assets_index.get_loc(asset_id), # Must be exact match.
)
cpdef _from_assets_and_dates(cls,
DatetimeIndex_t dates_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:236:29: 'DatetimeIndex_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
)
cpdef _from_assets_and_dates(cls,
DatetimeIndex_t dates_index,
Int64Index_t assets_index,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:237:29: 'Int64Index_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef _from_assets_and_dates(cls,
DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:238:29: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
cpdef _from_assets_and_dates(cls,
DatetimeIndex_t dates_index,
Int64Index_t assets_index,
Timestamp_t start_date,
Timestamp_t end_date,
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:239:29: 'Timestamp_t' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
from zipline.utils.compat import unicode
ADJUSTMENT_KIND_NAMES = {
MULTIPLY: 'MULTIPLY',
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:15:12: undeclared name not builtin: MULTIPLY
Error compiling Cython file:
------------------------------------------------------------
...
from zipline.utils.compat import unicode
ADJUSTMENT_KIND_NAMES = {
MULTIPLY: 'MULTIPLY',
ADD: 'ADD',
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:16:7: undeclared name not builtin: ADD
Error compiling Cython file:
------------------------------------------------------------
...
ADJUSTMENT_KIND_NAMES = {
MULTIPLY: 'MULTIPLY',
ADD: 'ADD',
OVERWRITE: 'OVERWRITE',
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:17:13: undeclared name not builtin: OVERWRITE
Error compiling Cython file:
------------------------------------------------------------
...
cdef type _choose_adjustment_type(AdjustmentKind adjustment_kind,
column_type value):
if adjustment_kind in (ADD, MULTIPLY):
if column_type is np.float64_t:
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:124:23: undeclared name not builtin: column_type
Error compiling Cython file:
------------------------------------------------------------
...
cdef type _choose_adjustment_type(AdjustmentKind adjustment_kind,
column_type value):
if adjustment_kind in (ADD, MULTIPLY):
if column_type is np.float64_t:
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:124:28: 'float64_t' is not a constant, variable or function identifier
Error compiling Cython file:
------------------------------------------------------------
...
type(value),
)
)
elif adjustment_kind == OVERWRITE:
if column_type is np.float64_t:
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:137:28: 'float64_t' is not a constant, variable or function identifier
Error compiling Cython file:
------------------------------------------------------------
...
)
elif adjustment_kind == OVERWRITE:
if column_type is np.float64_t:
return _float_adjustment_types[adjustment_kind]
elif column_type is np.int64_t:
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:139:30: 'int64_t' is not a constant, variable or function identifier
Error compiling Cython file:
------------------------------------------------------------
...
elif adjustment_kind == OVERWRITE:
if column_type is np.float64_t:
return _float_adjustment_types[adjustment_kind]
elif column_type is np.int64_t:
return _int_adjustment_types[adjustment_kind]
elif column_type is np.uint8_t:
^
------------------------------------------------------------
zipline/lib/adjustment.pyx:141:30: 'uint8_t' is not a constant, variable or function identifier
zipline/lib/adjustment.c:1:2: error: Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
building 'zipline.lib.adjustment' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/madhurn/.virtualenvs/zipline/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c zipline/lib/adjustment.c -o build/temp.macosx-10.6-intel-2.7/zipline/lib/adjustment.o
Here is how you can reproduce this issue on your machine:
Reproduction Steps
1. 2. 3. ...
What steps have you taken to resolve this already?
Not what what am i missing in the installation process.
Anything else?
...
Sincerely, Madhur
@madhurrajn I can't reproduce this on a fresh install:
(zipline) [~/quantopian/zipline]@(master:783cacd99b)$ history
...
500 rmvirtualenv zipline
501 mkvirtualenv -p python2 zipline
502 cd zipline/
503 git clone [email protected]:quantopian/zipline.git
504 ./etc/ordered_pip.sh etc/requirements.txt
505 pip install -r ./etc/requirements_dev.txt
506 pip install -r ./etc/requirements_blaze.txt
507 python2.7 setup.py build_ext --inplace
5508 history
(zipline) [~/quantopian/zipline]@(master:783cacd99b)$ python -c 'from zipline.algorithm import *'
Those errors look like they're caused by Cython failing to find type declarations for numpy and for some zipline libraries. I'm not sure offhand what might cause that. One possibility might be that mkvirtualenv created a python 3 virtualenv for you, in which case using python2.7 when invoking build_ext would still be using your system python2. Is there a particular reason you're invoking build_ext with a more specific python binary name?
Thanks @ssanderson. Indeed the problem was due to confusion of libraries between python 2 and python 3. By removing all the python 3 dependencies, the compilation is all fine. Thanks Again.
Hello ll..
Before I tell you about my issue, let me describe my environment: Environment
Operating System: (Windows 10
Python Version: $ python --version 3.7.3
I have installed python on path C:\Users\Admin\AppData\Local\Programs\Python\Python37-32
And I installed darkflow in this directory by using the tutorial
https://appliedmachinelearning.blog/2018/05/27/running-yolo-v2-for-real-time-object-detection-on-videos-images-via-darkflow/#respond
The problem occurs at this command
python3 setup.py build_ext --inplace
Error
C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\darkflow>python3 setup.py build_ext --inplace 'python3' is not recognized as an internal or external command, operable program or batch file.
So i when I run the command python3 setup.py build_ext --inplace i find error
I also tried it from the folder where it is unable to find the setup.py file C:\Users\Admin\AppData\Local\Programs\Python\Python37-32>python3 setup.py build_ext --inplace
I did everything mentioned in the turorial but as this does not work, I am unable to run the command which detects object in images which is
./flow –model cfg/yolov2.cfg –load bin/yolov2.weights –imgdir sample_img –gpu 0.9
So i get the error which is listed below with the command itself
C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\darkflow\darkflow\dark>./flow -model cfg/yolov2.cfg -load bin/yolov2.weights -imgdir sample_img -gpu 0.9 '.' is not recognized as an internal or external command, operable program or batch file.
Please help in running and sorting out the issue.
Thanks alot.