Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行代码时出现问题 #711

Closed
pjyaaa opened this issue Aug 17, 2023 · 5 comments
Closed

运行代码时出现问题 #711

pjyaaa opened this issue Aug 17, 2023 · 5 comments
Labels
bug Something isn't working info Informational

Comments

@pjyaaa
Copy link

pjyaaa commented Aug 17, 2023

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)

0.3.140

Do you have TA Lib also installed in your environment?

$ pip list

Have you tried the development version? Did it resolve the issue?

$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Provide sample code.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Thanks for using Pandas TA!

运行代码如下:

import qstock as qs
import pandas_ta as ta
import matplotlib.pyplot as plt
#正常复制一个dataframe显示画图时出现的中文和负号
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False

#以中国平安保险股票数据为例,获取后复权价格
df0 = qs.get_data('中国平安',start='20200807',end='20230807',fqt=2)[['open','high','low','close','volume']]

# 复制一个dataframe
df = df0.copy(deep=True)
#添加与k线图模式相关的指标
df.ta.strategy('candles')
print(df.columns)
print(f'指标特征个数: {len(df.columns)-5}')
运行错误信息如下:
File "<string>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\androidstudy\pandasTA\candles.py", line 15, in <module>
    df.ta.strategy('candles')
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas_ta\core.py", line 725, in strategy
    with Pool(self.cores) as pool:
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 212, in __init__
    self._repopulate_pool()
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

反复出现以上错误信息。

@pjyaaa pjyaaa added the bug Something isn't working label Aug 17, 2023
@pjyaaa
Copy link
Author

pjyaaa commented Aug 17, 2023

Successfully installed Lib-4.0.0 TA-0.10.2

@pjyaaa
Copy link
Author

pjyaaa commented Aug 17, 2023

@twopirllc
Copy link
Owner

Hello @pjyaaa,

See #181 or #282

Kind Regards,
KJ

@twopirllc twopirllc removed their assignment Aug 17, 2023
@twopirllc twopirllc added the info Informational label Aug 17, 2023
@pjyaaa
Copy link
Author

pjyaaa commented Aug 18, 2023

问题已经解决,谢谢,主要是要把代码封装到一个函数内,通过if name=='main':方式就不会再出现上述错误信息。

@pjyaaa pjyaaa closed this as completed Aug 18, 2023
@pjyaaa
Copy link
Author

pjyaaa commented Aug 18, 2023

问题已经解决,谢谢,主要是要把代码封装到一个函数内,通过if --name--=='--main--':方式调用函数就不会再出现上述错误信息。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working info Informational
Projects
None yet
Development

No branches or pull requests

2 participants