Tag Archives: Python notes

Troubleshooting of errors in the installation and use of scienceplots

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!

error: Microsoft Visual C++ 9.0 is required

Install scrapy with PIP under windows and report the following error. Just look at the error prompt http://aka.ms/vcpython27 There’s a solution

error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat ). Get it from http://aka.ms/vcpython27

open http://aka.ms/vcpython27 Will jump to http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266

Download the installation package

Microsoft Visual C + + compiler for Python 2.7
can be installed back to solve the problem

http://blog.chedushi.com/archives/10610

Python keyerror exception

If you don’t know if there’s a key value in dict, you’d better use it

dict.get(key)
If you read with dict[key] it will report a KeyError exception,

Dict. Get method mainly provides a function to return the default value if the value of corresponding key is not obtained.

And dict[key] actually calls the method with ___
D.get(key[, d]) -> D[K] if K in D, else D. defaults to None