quantopian / pyfolio

Portfolio and risk analytics in Python
https://quantopian.github.io/pyfolio
Apache License 2.0
5.69k stars 1.78k forks source link

How to install it... there is always something wrong when I install it under Window #597

Open jaffa4 opened 5 years ago

jaffa4 commented 5 years ago

Problem Description

Please provide a minimal, self-contained, and reproducible example:

[Paste code here]

I try to install under Window 7. I have tried several python version... Something always wrong Either I cannot install numpy Or theana If I install them Then

folio) F:\Miniconda3\envs\folio>python D:\m\python\pyfolioexample\main.py
raceback (most recent call last):
 File "D:\m\python\pyfolioexample\main.py", line 14, in <module>
   pf.create_bayesian_tear_sheet(stock_rets, live_start_date=out_of_sample,benchmark_rets = None)
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\plotting.py", line 49, in call_w_context
   return func(*args, **kwargs)
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\tears.py", line 849, in create_bayesian_tear_sheet
   end=returns.index[-1]))
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\utils.py", line 475, in get_symbol_rets
   end=end)
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\utils.py", line 258, in default_returns_func
   end=datetime.now())
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\utils.py", line 171, in get_returns_cached
   returns = update_func(**kwargs)
 File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\utils.py", line 214, in get_symbol_from_yahoo
   px = web.get_data_yahoo(symbol, start=start, end=end)
 File "F:\Miniconda3\envs\folio\lib\site-packages\pandas_datareader\data.py", line 70, in get_data_yahoo
   return YahooDailyReader(*args, **kwargs).read()
 File "F:\Miniconda3\envs\folio\lib\site-packages\pandas_datareader\base.py", line 210, in read
   params=self._get_params(self.symbols))
 File "F:\Miniconda3\envs\folio\lib\site-packages\pandas_datareader\yahoo\daily.py", line 106, in _get_params
   unix_start = int(time.mktime(self.start.timetuple()))
verflowError: mktime argument out of range

Please provide the full traceback:

[Paste traceback here]

can you recommond an exact sequence of installation.. including python version , what modules to install and from where.. for Windows? Thanks.... Please provide any additional information below:

Versions

twiecki commented 5 years ago

That looks like a pandas_datareader error.

jaffa4 commented 5 years ago

Meaning what? Example is bad or datareader library is buggy?

twiecki commented 5 years ago

The datareader library is buggy. I thought we made that optional, however, are you on the most recent version?

On Sat, Apr 13, 2019 at 6:46 AM jaffa4 notifications@github.com wrote:

Meaning what? Example is bad or datareader library is buggy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/quantopian/pyfolio/issues/597#issuecomment-482775899, or mute the thread https://github.com/notifications/unsubscribe-auth/AApJmG2RtTKwysZ4lwv65XxGUdYIsHUMks5vgWERgaJpZM4csP1s .

twiecki commented 5 years ago

Can you try again installing the new version?

jaffa4 commented 5 years ago

New problem

F:\Miniconda3\envs\folio\python.exe D:/m/python/pyfolioexample/main.py Running T model F:\Miniconda3\envs\folio\lib\site-packages\pymc3\tuning\starting.py:61: UserWarning: find_MAP should not be used to initialize the NUTS sampler, simply call pymc3.sample() and it will automatically initialize NUTS in a better way. warnings.warn('find_MAP should not be used to initialize the NUTS sampler, simply call pymc3.sample() and it will automatically initialize NUTS in a better way.') F:\Miniconda3\envs\folio\lib\site-packages\pymc3\tuning\starting.py:102: UserWarning: In future versions, set the optimization algorithm with a string. For example, use method="L-BFGS-B" instead of fmin=sp.optimize.fmin_l_bfgs_b". warnings.warn('In future versions, set the optimization algorithm with a string. ' logp = 3,754.2: 2%|▏ | 100/5000 [00:00<00:00, 5882.04it/s]Optimization terminated successfully. logp = 4,088.5: 2%|▏ | 110/5000 [00:00<00:00, 5789.17it/s] Current function value: -4088.496490 Iterations: 3 Function evaluations: 117 logp = 4,088.5: 2%|▏ | 117/5000 [00:00<00:22, 215.85it/s] F:\Miniconda3\envs\folio\lib\site-packages\theano\scan_module\scan_perform_ext.py:76: UserWarning: The file scan_perform.c is not available. This donot happen normally. You are probably in a strangesetup. This mean Theano can not use the cython code for scan. If youwant to remove this warning, use the Theano flag'cxx=' (set to an empty string) to disable all ccode generation. "The file scan_perform.c is not available. This do" F:\Miniconda3\envs\folio\lib\site-packages\theano\scan_module\scan_perform_ext.py:76: UserWarning: The file scan_perform.c is not available. This donot happen normally. You are probably in a strangesetup. This mean Theano can not use the cython code for scan. If youwant to remove this warning, use the Theano flag'cxx=' (set to an empty string) to disable all ccode generation. "The file scan_perform.c is not available. This do" F:\Miniconda3\envs\folio\lib\site-packages\theano\scan_module\scan_perform_ext.py:76: UserWarning: The file scan_perform.c is not available. This donot happen normally. You are probably in a strangesetup. This mean Theano can not use the cython code for scan. If youwant to remove this warning, use the Theano flag'cxx=' (set to an empty string) to disable all ccode generation. "The file scan_perform.c is not available. This do" F:\Miniconda3\envs\folio\lib\site-packages\theano\scan_module\scan_perform_ext.py:76: UserWarning: The file scan_perform.c is not available. This donot happen normally. You are probably in a strangesetup. This mean Theano can not use the cython code for scan. If youwant to remove this warning, use the Theano flag'cxx=' (set to an empty string) to disable all ccode generation. "The file scan_perform.c is not available. This do" Multiprocess sampling (2 chains in 2 jobs) NUTS: [nu_minus_two, volatility, mean returns] Running T model F:\Miniconda3\envs\folio\lib\site-packages\pymc3\tuning\starting.py:61: UserWarning: find_MAP should not be used to initialize the NUTS sampler, simply call pymc3.sample() and it will automatically initialize NUTS in a better way. warnings.warn('find_MAP should not be used to initialize the NUTS sampler, simply call pymc3.sample() and it will automatically initialize NUTS in a better way.') Traceback (most recent call last): File "", line 1, in File "F:\Miniconda3\envs\folio\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) File "F:\Miniconda3\envs\folio\lib\multiprocessing\spawn.py", line 114, in _main prepare(preparation_data) File "F:\Miniconda3\envs\folio\lib\multiprocessing\spawn.py", line 225, in prepare _fixup_main_from_path(data['init_main_from_path']) File "F:\Miniconda3\envs\folio\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path run_name="mp_main") File "F:\Miniconda3\envs\folio\lib\runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname) File "F:\Miniconda3\envs\folio\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "F:\Miniconda3\envs\folio\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\m\python\pyfolioexample\main.py", line 15, in pf.create_bayesian_tear_sheet(stock_rets, live_start_date=out_of_sample,benchmark_rets = stock_rets) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\plotting.py", line 49, in call_w_context return func(*args, *kwargs) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\tears.py", line 870, in create_bayesian_tear_sheet samples=samples, ppc=True) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\bayesian.py", line 584, in run_model model, trace = model_returns_t(returns_train, samples) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\bayesian.py", line 185, in model_returns_t start = pm.find_MAP(fmin=sp.optimize.fmin_powell) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\tuning\starting.py", line 87, in find_MAP dlogp_func = bij.mapf(model.fastdlogp_nojac(vars)) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\model.py", line 250, in fastdlogp_nojac Traceback (most recent call last): File "D:/m/python/pyfolioexample/main.py", line 15, in return self.model.fastfn(gradient(self.logp_nojact, vars)) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\theanof.py", line 96, in gradient pf.create_bayesian_tear_sheet(stock_rets, live_start_date=out_of_sample,benchmark_rets = stock_rets) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\plotting.py", line 49, in call_w_context return tt.concatenate([gradient1(f, v) for v in vars], axis=0) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\theanof.py", line 96, in return func(args, kwargs) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\tears.py", line 870, in create_bayesian_tear_sheet return tt.concatenate([gradient1(f, v) for v in vars], axis=0) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\theanof.py", line 85, in gradient1 return tt.flatten(tt.grad(f, v, disconnected_inputs='warn')) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\tensor\basic.py", line 5276, in flatten samples=samples, ppc=True) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\bayesian.py", line 584, in run_model model, trace = model_returns_t(returns_train, samples) File "F:\Miniconda3\envs\folio\lib\site-packages\pyfolio\bayesian.py", line 187, in model_returns_t trace = pm.sample(samples, step, start=start) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\sampling.py", line 439, in sample trace = _mp_sample(sample_args) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\sampling.py", line 986, in _mp_sample chain, progressbar) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\parallel_sampling.py", line 313, in init for chain, seed, start in zip(range(chains), seeds, start_points) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\parallel_sampling.py", line 313, in for chain, seed, start in zip(range(chains), seeds, start_points) File "F:\Miniconda3\envs\folio\lib\site-packages\pymc3\parallel_sampling.py", line 204, in init self._process.start() File "F:\Miniconda3\envs\folio\lib\multiprocessing\process.py", line 112, in start self._popen = self._Popen(self) File "F:\Miniconda3\envs\folio\lib\multiprocessing\context.py", line 223, in _Popen x_reshaped = x.reshape(dims) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\tensor\var.py", line 321, in reshape return _default_context.get_context().Process._Popen(process_obj) File "F:\Miniconda3\envs\folio\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "F:\Miniconda3\envs\folio\lib\multiprocessing\popen_spawn_win32.py", line 89, in init return theano.tensor.basic.reshape(self, shape, ndim=ndim) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\tensor\basic.py", line 5047, in reshape reduction.dump(process_obj, to_child) File "F:\Miniconda3\envs\folio\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) BrokenPipeError: [Errno 32] Broken pipe rval = op(x, newshape) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\op.py", line 670, in call__ no_recycling=[]) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\op.py", line 955, in make_thunk no_recycling) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\op.py", line 858, in make_c_thunk output_storage=node_output_storage) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cc.py", line 1217, in make_thunk keep_lock=keep_lock) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cc.py", line 1157, in compile__ keep_lock=keep_lock) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cc.py", line 1620, in cthunk_factory key=key, lnk=self, keep_lock=keep_lock) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cmodule.py", line 1181, in module_from_key module = lnk.compile_cmodule(location) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cc.py", line 1523, in compile_cmodule preargs=preargs) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cmodule.py", line 2400, in compile_str return dlimport(lib_filename) File "F:\Miniconda3\envs\folio\lib\site-packages\theano\gof\cmodule.py", line 309, in dlimport rval = import(module_name, {}, {}, [module_name]) ImportError: DLL load failed: The specified procedure could not be found.

Process finished with exit code 1

twiecki commented 5 years ago

Maybe just don't run the bayesian tearsheet. Or use conda to install pymc3.

jaffa4 commented 5 years ago

I used conda.before running that.

(folio) f:\Miniconda3\Scripts>conda install pymc3 Collecting package metadata: done Solving environment: done

==> WARNING: A newer version of conda exists. <== current version: 4.6.12 latest version: 4.6.13

Please update conda by running

$ conda update -n base conda

Package Plan

environment location: f:\Miniconda3\envs\folio

added / updated specs:

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
certifi-2019.3.9           |           py37_0         149 KB  conda-forge
h5py-2.9.0                 |nompi_py37h3cb27cb_1102         905 KB  conda-forge
hdf5-1.10.4                |nompi_hcc15c50_1106        34.9 MB  conda-forge
joblib-0.12.5              |             py_0         176 KB  conda-forge
pymc3-3.6                  |        py37_1000        1022 KB  conda-forge
pyreadline-2.1             |        py37_1000         140 KB  conda-forge
tqdm-4.31.1                |             py_0          40 KB  conda-forge
------------------------------------------------------------
                                       Total:        37.3 MB

The following NEW packages will be INSTALLED:

h5py conda-forge/win-64::h5py-2.9.0-nompi_py37h3cb27cb_1102 hdf5 conda-forge/win-64::hdf5-1.10.4-nompi_hcc15c50_1106 joblib conda-forge/noarch::joblib-0.12.5-py_0 pymc3 conda-forge/win-64::pymc3-3.6-py37_1000 pyreadline conda-forge/win-64::pyreadline-2.1-py37_1000 tqdm conda-forge/noarch::tqdm-4.31.1-py_0

The following packages will be UPDATED:

ca-certificates pkgs/main::ca-certificates-2019.1.23-0 --> conda-forge::ca-certificates-2019.3.9-h openssl pkgs/main::openssl-1.1.1b-he774522_1 --> conda-forge::openssl-1.1.1b-hfa6e2cd_2

The following packages will be SUPERSEDED by a higher-priority channel:

certifi pkgs/main --> conda-forge

Proceed ([y]/n)? y

Downloading and Extracting Packages tqdm-4.31.1 | 40 KB | ############################################################ | 100% certifi-2019.3.9 | 149 KB | ############################################################ | 100% hdf5-1.10.4 | 34.9 MB | ############################################################ | 100% h5py-2.9.0 | 905 KB | ############################################################ | 100% pyreadline-2.1 | 140 KB | ############################################################ | 100% pymc3-3.6 | 1022 KB | ############################################################ | 100% joblib-0.12.5 | 176 KB | ############################################################ | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done

(folio) f:\Miniconda3\Scripts>