配置
python 3.8.5
anaconda
spyder 4
spyder编辑器有很好的的图形界面,所绘制图形直观反馈在界面中,终端和pycharm运行python绘图则需要plot后才会有图像显示。
因此,个人习惯使用Spyder。
(1)SciencePlots工具包需要提前安装好Latex,之前使用过latex的忽略,建议官网下载并安装miktex链接: link.
这一步非常重要,在conda中安装latex不行,必须在win10中安装latex,详情看下一部分。
(2)安装SciencePlots
Github链接: link.中给出了三种方式,都可以。
The easiest way to install SciencePlots is by using `pip`: ```bash # to install the lastest release (from PyPI) pip install SciencePlots # to install the latest commit (from GitHub) pip install git+https://github.com/garrettj403/SciencePlots # to clone and install from a local copy git clone https://github.com/garrettj403/SciencePlots.git cd SciencePlots pip install -e .
(3)测试一下,可以使用说明安装成功。
import matplotlib.pyplot as plt
plt.style.use('science')
fig, axe = plt.subplots(2, 2, figsize=(5,5))
2、遇到的问题
主要遇到了两个错误:
File "C:Usersdellanaconda3libsubprocess.py", line 1307, in _execute_chi RuntimeError: Failed to process string with tex because latex could not be found)
俩错误按照顺序发生,报错的意思是第一个错误直接导致第二个错误什么什么的。。。我就以为是内核错误,疯狂改这个bug,anaconda卸载重装,jupyter、spyder编辑器和xlrd、matplotlib、 SciencePlots等包疯狂卸载重装,最后我终于确定这些东西都没问题。。。。。
在安装时候我已经注意到read me中提示需要提前安装Latex,我寻思我都在anaconda中安装过latex了,就没在注意这句话,最后试过所有的方法,我突然意识到应该是在Win下安装latex。果然安装好miktex之后再次运行画图代码的时候没有报错,运行几秒钟之后开始提示安装一些latex包中确实的宏,安装好就可以运行了!
真特么坑。。。花费了那么长时间改bug,其实就这么一点小问题,反思自己,以后看说明一定要认真多思考!



