Matplotlib created a temporary config/cache directory at C:\Users\Elegent\AppData\Local\Temp\matplotlib-zx380bwq because the default path (C:\Users\Elegent.matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing. Traceback (most recent call last): File "D:\pythonProject\AppleStock\ananly2.py", line 24, in <module> candlestick_ochl(ax, df[["Open", "Close", "High", "Low"]].values, width=0.5, colorup="green", colordown="red") File "D:\pythonProject\venv\lib\site-packages\mplfinance\original_flavor.py", line 195, in candlestick_ochl return _candlestick(ax, quotes, width=width, colorup=colorup, File "D:\pythonProject\venv\lib\site-packages\mplfinance\original_flavor.py", line 281, in _candlestick t, open, close, high, low = q[:5] ValueError: not enough values to unpack (expected 5, got 4)
时间: 2023-07-05 12:26:24 浏览: 154
这个错误似乎是你的代码中使用了一个函数 `candlestick_ochl`,但是该函数的参数缺少了一些必要的值,导致无法正确执行。具体来说,该函数需要一个包含5个值的列表,但是你只提供了4个。你需要检查你的代码并确保提供了正确数量的参数。同时,你也可以尝试设置 MPLCONFIGDIR 环境变量以解决 Matplotlib 报错的问题。
相关问题
PS D:\pythonProject> pip install matplotlib Collecting matplotlib Obtaining dependency information for matplotlib from https://files.pythonhosted.org/packages/d0/39/4c4fb38ec2356bcbc9017a5421623aec69aacde110e4e76d34d0a43702f0/matplotlib-3.7.2-cp310-cp310-win32.whl.metadata Using cached matplotlib-3.7.2-cp310-cp310-win32.whl.metadata (5.8 kB) Collecting contourpy>=1.0.1 (from matplotlib) Using cached contourpy-1.1.0.tar.gz (13.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [25 lines of output] + meson setup C:\Users\张豪\AppData\Local\Temp\pip-install-fuirjkwl\contourpy_ab1b9965df3941b882963f3350114322 C:\Users\张豪\AppData\Local\Temp\pip-install-fuirjkwl\contourpy_ab1 b9965df3941b882963f3350114322\.mesonpy-qrhmsqrm\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\张豪\AppData\Local\Temp\pip-install-fuirjkwl\contourpy_ab1b9965df3941b882963f3350114322\.mesonpy-qrhmsqrm\build\meson-python-native-file.ini The Meson build system Version: 1.2.0 Source dir: C:\Users\张豪\AppData\Local\Temp\pip-install-fuirjkwl\contourpy_ab1b9965df3941b882963f3350114322 Build dir: C:\Users\张豪\AppData\Local\Temp\pip-install-fuirjkwl\contourpy_ab1b9965df3941b882963f3350114322\.mesonpy-qrhmsqrm\build Build type: native build Project name: contourpy Project version: 1.1.0 Activating VS 17.6.5 note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
这个错误是由于缺少构建依赖项导致的。在安装 matplotlib 之前,您需要安装一些必要的库。请按照以下步骤操作:
1. 打开命令提示符或终端,并确保您的计算机已连接到互联网。
2. 运行以下命令来安装构建工具:
```
pip install build
```
3. 安装完构建工具后,再次尝试安装 matplotlib:
```
pip install matplotlib
```
这样应该可以解决您遇到的问题。如果仍然有任何疑问,请随时提问。
阅读全文