Troubleshooting of errors in the installation and use of scienceplots
Configure
Python 3.8.5
Anaconda
Spyder 4
Spyder editor has a good graphical interface. The drawn graphics are directly fed back in the interface. When the terminal and pycharm run Python drawing, the image will be displayed only after plot
therefore, I am used to using Spyder.
1. Scienceplots installation
(1) The scienceplots toolkit needs to install latex in advance. If latex has been used before, it is ignored. It is recommended to download and install the miktex link on the official website: link.
this step is very important. Installing latex in CONDA is not enough. You must install latex in win10. See the next section for details.
(2) Install scienceplots
GitHub link: link. Provides three methods, all of which are OK.
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) Test it. It can be used to indicate that the installation is successful.
import matplotlib.pyplot as plt
plt.style.use('science')
fig, axe = plt.subplots(2, 2, figsize=(5,5))
2. Problems encountered
Two main errors were encountered:
File "C:\Users\dell\anaconda3\lib\subprocess.py", line 1307, in _execute_chi
RuntimeError: Failed to process string with tex because latex could not be found)
Two errors occur in sequence. Error reporting means that the first error directly leads to the second error… I thought it was a kernel error. I changed the bug crazily. Anaconda uninstalled and reinstalled. Jupyter, spyder editor, xlrd, Matplotlib, scienceplots and other packages uninstalled and reinstalled crazily. Finally, I finally determined that these things were ok…..
During installation, I noticed the prompt in read me that latex needs to be installed in advance. I thought I had installed latex in anaconda, but I didn’t pay attention to this sentence. Finally, I tried all the methods. I suddenly realized that latex should be installed under win. Sure enough, there is no error when running the drawing code again after installing miktex. After running for a few seconds, you will be prompted to install some real macros in the latex package. After installation, you can run!
Really special pit… It took so long to fix the bug. In fact, it’s just such a small problem. Reflect on yourself. In the future, you must think more seriously!