Skip to content

Mac import 直接报错 #50

@QYQSDTC

Description

@QYQSDTC

Python 版本 3.10,import 直接报错

import qstock as qs
/Users/yiqianqian/miniforge3/envs/quant/lib/python3.10/site-packages/py_mini_racer/py_mini_racer.py:13: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources

You can find the C code in this temporary file: /var/folders/l0/2jp7c8zs5r71068bss16pyxm0000gn/T/theano_compilation_error_qg3gdeuk
------------------------------------------------------------------------
ImportError                            Traceback (most recent call last)
File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/gof/lazylinker_c.py:76
     75         if version != actual_version:
---> 76             raise ImportError(
     77                 "Version check of the existing lazylinker compiled file."
     78                 " Looking for version %s, but found %s. "
     79                 "Extra debug information: force_compile=%s, _need_reload=%s" % (
     80                     version,
     81                     actual_version, force_compile, _need_reload))
     82 except ImportError:

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

ImportError                            Traceback (most recent call last)
File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/gof/lazylinker_c.py:99
     98     if version != actual_version:
---> 99         raise ImportError(
    100             "Version check of the existing lazylinker compiled file."
    101             " Looking for version %s, but found %s. "
    102             "Extra debug information: force_compile=%s,"
    103             " _need_reload=%s" % (
    104                 version,
    105                 actual_version, force_compile, _need_reload))
    106 except ImportError:
    107     # It is useless to try to compile if there isn't any
    108     # compiler!  But we still want to try to load it, in case
    109     # the cache was copied from another computer.

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

Exception                              Traceback (most recent call last)
Cell In[1], line 1
----> 1 import qstock as qs

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/qstock/__init__.py:31
     28 from qstock.stock.ths_em_pool import *
     30 #回测模块
---> 31 from qstock.backtest.vec_backtest import *
     32 from qstock.backtest.turtle import *
     33 from qstock.backtest.bt_backtest import *

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/qstock/backtest/__init__.py:13
      9 from .vec_backtest import *
     11 from .turtle import *
---> 13 from .bt_backtest import *

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/qstock/backtest/bt_backtest.py:14
     12 # 忽略UserWarning(缺失zipline.assets )
     13 warnings.filterwarnings("ignore",  message="Module \"zipline.assets\"  not found")
---> 14 import pyfolio as pf
     16 def bt_result(code='sh',start='2000-01-01', end=None,
     17               strategy=None,startcash=10000000.0,commission=0.00):
     18     '''code:回测代码或简称列表(list)或数据的字典格式
     19        start,end为回测起始日期,格式为'2023-08-04'
     20        strategy:策略名称
     21        startcash:初始资金
     22        commission:手续费
     23     '''

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/pyfolio/__init__.py:13
     10 from . import risk
     11 from . import perf_attrib
---> 13 from .tears import *  # noqa
     14 from .plotting import *  # noqa
     15 from ._version import get_versions

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/pyfolio/tears.py:38
     35 from . import utils
     37 try:
---> 38     from . import bayesian
     39     have_bayesian = True
     40 except ImportError:

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/pyfolio/bayesian.py:24
     20 from scipy import stats
     22 import matplotlib.pyplot as plt
---> 24 import pymc3 as pm
     26 try:
     27     from pymc3 import StudentT

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/pymc3/__init__.py:38
     34     current = theano.config.gcc.cxxflags
     35     theano.config.gcc.cxxflags = f"{current} -Wno-c++11-narrowing"
---> 38 __set_compiler_flags()
     40 from .blocking import *
     41 from .distributions import *

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/pymc3/__init__.py:33, in __set_compiler_flags()
     31 def __set_compiler_flags():
     32     # Workarounds for Theano compiler problems on various platforms
---> 33     import theano
     34     current = theano.config.gcc.cxxflags
     35     theano.config.gcc.cxxflags = f"{current} -Wno-c++11-narrowing"

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/__init__.py:110
     97 __api_version__ = 1
     99 from theano.gof import (
    100     CLinker, OpWiseCLinker, DualLinker, Linker, LocalLinker, PerformLinker,
    101     Container,
   (...)
    107     Type, Generic, generic,
    108     object2, utils)
--> 110 from theano.compile import (
    111     SymbolicInput, In,
    112     SymbolicOutput, Out,
    113     Mode,
    114     predefined_modes, predefined_linkers, predefined_optimizers,
    115     FunctionMaker, function, function_dump,
    116     OpFromGraph,
    117     ProfileStats,
    118     Param, shared, as_op)
    120 from theano.misc.safe_asarray import _asarray
    122 from theano.printing import pprint, pp

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/compile/__init__.py:12
      2 from theano.compile.ops import (
      3         DeepCopyOp, deep_copy_op, register_deep_copy_op_c_code,
      4         Shape, shape, register_shape_c_code,
   (...)
      7         as_op, Rebroadcast, register_rebroadcast_c_code,
      8         SpecifyShape, specify_shape, register_specify_shape_c_code)
     10 from theano.compile.function_module import *
---> 12 from theano.compile.mode import *
     14 from theano.compile.io import *
     16 from theano.compile.debugmode import DebugMode

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/compile/mode.py:11
      9 import theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano import config
     13 from six import string_types

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/gof/vm.py:674
    672 if not theano.config.cxx:
    673     raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 674 from . import lazylinker_c
    676 class CVM(lazylinker_c.CLazyLinker, VM):
    678     def __init__(self, *args, **kwargs):

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/gof/lazylinker_c.py:139
    136         assert os.path.exists(loc)
    138 args = cmodule.GCC_compiler.compile_args()
--> 139 cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
    140                                  preargs=args)
    141 # Save version into the __init__.py file.
    142 init_py = os.path.join(loc, '__init__.py')

File ~/miniforge3/envs/quant/lib/python3.10/site-packages/theano/gof/cmodule.py:2410, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2403                 print(
   2404                     'Check if package python-dev or python-devel is installed.'
   2405                 )
   2407     # We replace '\n' by '. ' in the error message because when Python
   2408     # prints the exception, having '\n' in the text makes it more
   2409     # difficult to read.
-> 2410     raise Exception('Compilation failed (return status=%s): %s' %
   2411                     (status, compile_stderr.replace('\n', '. ')))
   2412 elif config.cmodule.compilation_warning and compile_stderr:
   2413     # Print errors just below the command line.
   2414     print(compile_stderr)

Exception: Compilation failed (return status=1): In file included from /Users/yiqianqian/.theano/compiledir_macOS-15.3.2-arm64-arm-64bit-arm-3.10.18-64/lazylinker_ext/mod.cpp:1:. /Users/yiqianqian/miniforge3/envs/quant/include/python3.10/Python.h:25:10: fatal error: 'stdio.h' file not found. #include <stdio.h>.          ^~~~~~~~~. 1 error generated..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions