3b1b / manim

Animation engine for explanatory math videos
MIT License
70.45k stars 6.2k forks source link

LaTeX Error: File `preview.sty' not found. #2101

Open Rasputin2 opened 8 months ago

Rasputin2 commented 8 months ago

This is the example I was trying to run using Manim (it comes from the website):

class MovingAngle(Scene):
    def construct(self):
        rotation_center = LEFT

        theta_tracker = ValueTracker(110)
        line1 = Line(LEFT, RIGHT)
        line_moving = Line(LEFT, RIGHT)
        line_ref = line_moving.copy()
        line_moving.rotate(
            theta_tracker.get_value() * DEGREES, about_point=rotation_center
        )
        a = Angle(line1, line_moving, radius=0.5, other_angle=False)
        tex = MathTex(r"\theta").move_to(
            Angle(
                line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
            ).point_from_proportion(0.5)
        )

        self.add(line1, line_moving, a, tex)
        self.wait()

        line_moving.add_updater(
            lambda x: x.become(line_ref.copy()).rotate(
                theta_tracker.get_value() * DEGREES, about_point=rotation_center
            )
        )

        a.add_updater(
            lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))
        )
        tex.add_updater(
            lambda x: x.move_to(
                Angle(
                    line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
                ).point_from_proportion(0.5)
            )
        )

        self.play(theta_tracker.animate.set_value(40))
        self.play(theta_tracker.animate.increment_value(140))
        self.play(tex.animate.set_color(RED), run_time=0.5)
        self.play(theta_tracker.animate.set_value(350))

I got a couple of errors, searched for the solution, and discovered I needed MikTek and also that I needed to add MikTek to my PATH environment variables. I got that from issue #623. OK. So I did that. Now, when I run this, I get the following traceback and value error:

image

When I look at the log file it shows this:

entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**./media/Tex/26ec1c2309a05843.tex
(media/Tex/26ec1c2309a05843.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-01-04>

(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/standalone\standalone.c
ls
Document Class: standalone 2022/10/10 v1.3b Class to compile TeX sub-files stan
dalone
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/tools\shellesc.sty
Package: shellesc 2023/07/08 v1.0d unified shell escape interface for LaTeX
Package shellesc Info: Restricted shell escape enabled on input line 77.
) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/xkeyval\xkeyval.sty
Package: xkeyval 2022/06/16 v2.9 package option processing (HA)
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\xkeyval.tex (
C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\xkvutils.tex
\XKV@toks=\toks17
\XKV@tempa@toks=\toks18
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\keyval.tex))
\XKV@depth=\count187
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
\sa@internal=\count188
\c@sapage=\count189

(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/standalone\standalone.c
fg
File: standalone.cfg 2022/10/10 v1.3b Default configuration file for 'standalon
e' class
) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count190
\c@section=\count191
\c@subsection=\count192
\c@subsubsection=\count193
\c@paragraph=\count194
\c@subparagraph=\count195
\c@figure=\count196
\c@table=\count197
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)

! LaTeX Error: File `preview.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.572 \ifsa@multi
                 \else^^M 
Here is how much of TeX's memory you used:
 810 strings out of 474487
 13939 string characters out of 5743781
 1924539 words of memory out of 5000000
 23157 multiletter control sequences out of 15000+600000
 558069 words of font info for 36 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 57i,0n,71p,207b,36s stack positions out of 10000i,1000n,20000p,200000b,200000s

No pages of output.
Prometheus-first commented 8 months ago

I meet the same question, it's disturbing, please tell me if anybody knows how to solve this problem

Prometheus-first commented 8 months ago

This is the example I was trying to run using Manim (it comes from the website):

class MovingAngle(Scene):
    def construct(self):
        rotation_center = LEFT

        theta_tracker = ValueTracker(110)
        line1 = Line(LEFT, RIGHT)
        line_moving = Line(LEFT, RIGHT)
        line_ref = line_moving.copy()
        line_moving.rotate(
            theta_tracker.get_value() * DEGREES, about_point=rotation_center
        )
        a = Angle(line1, line_moving, radius=0.5, other_angle=False)
        tex = MathTex(r"\theta").move_to(
            Angle(
                line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
            ).point_from_proportion(0.5)
        )

        self.add(line1, line_moving, a, tex)
        self.wait()

        line_moving.add_updater(
            lambda x: x.become(line_ref.copy()).rotate(
                theta_tracker.get_value() * DEGREES, about_point=rotation_center
            )
        )

        a.add_updater(
            lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))
        )
        tex.add_updater(
            lambda x: x.move_to(
                Angle(
                    line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
                ).point_from_proportion(0.5)
            )
        )

        self.play(theta_tracker.animate.set_value(40))
        self.play(theta_tracker.animate.increment_value(140))
        self.play(tex.animate.set_color(RED), run_time=0.5)
        self.play(theta_tracker.animate.set_value(350))

I got a couple of errors, searched for the solution, and discovered I needed MikTek and also that I needed to add MikTek to my PATH environment variables. I got that from issue #623. OK. So I did that. Now, when I run this, I get the following traceback and value error:

image

When I look at the log file it shows this:

entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**./media/Tex/26ec1c2309a05843.tex
(media/Tex/26ec1c2309a05843.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-01-04>

(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/standalone\standalone.c
ls
Document Class: standalone 2022/10/10 v1.3b Class to compile TeX sub-files stan
dalone
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/tools\shellesc.sty
Package: shellesc 2023/07/08 v1.0d unified shell escape interface for LaTeX
Package shellesc Info: Restricted shell escape enabled on input line 77.
) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/xkeyval\xkeyval.sty
Package: xkeyval 2022/06/16 v2.9 package option processing (HA)
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\xkeyval.tex (
C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\xkvutils.tex
\XKV@toks=\toks17
\XKV@tempa@toks=\toks18
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/generic/xkeyval\keyval.tex))
\XKV@depth=\count187
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
\sa@internal=\count188
\c@sapage=\count189

(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/standalone\standalone.c
fg
File: standalone.cfg 2022/10/10 v1.3b Default configuration file for 'standalon
e' class
) (C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\mcdnj\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count190
\c@section=\count191
\c@subsection=\count192
\c@subsubsection=\count193
\c@paragraph=\count194
\c@subparagraph=\count195
\c@figure=\count196
\c@table=\count197
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)

! LaTeX Error: File `preview.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.572 \ifsa@multi
                 \else^^M 
Here is how much of TeX's memory you used:
 810 strings out of 474487
 13939 string characters out of 5743781
 1924539 words of memory out of 5000000
 23157 multiletter control sequences out of 15000+600000
 558069 words of font info for 36 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 57i,0n,71p,207b,36s stack positions out of 10000i,1000n,20000p,200000b,200000s

No pages of output.

fortunately,i resolved this problem, you should open miktex console(if you are using this tool),and then Check for updates,later you should find the include package and install preview image

Rasputin2 commented 8 months ago

I agree with the commentator. That is how I was able to get it to run - installing MikTek is not sufficient. You have to then open up the console and also install whatever package you are using.

JohnLulzh2002 commented 7 months ago

It works for me. I don't know why MiKTeX failed to install on the fly. ☹