|
| 1 | +# FAQ: General Usage |
| 2 | + |
| 3 | +## Why does Manim say that "there are no scenes inside that module"? |
| 4 | + |
| 5 | +There are two main reasons why this error appears: if you have edited |
| 6 | +the file containing your `Scene` class and forgot to save it, or if you |
| 7 | +have accidentally passed the name of a wrong file to `manim`, this is |
| 8 | +a likely outcome. Check that you have spelled everything correctly. |
| 9 | + |
| 10 | +Otherwise you are likely mixing up Manim versions. See {ref}`this FAQ answer <different-versions>` |
| 11 | +for an explanation regarding why there are different versions. Under the assumption |
| 12 | +that you are trying to use the `manim` executable from the terminal to run |
| 13 | +a scene that has been written for the community version (i.e., there is |
| 14 | +`from manim import *`, or more specifically `from manim import Scene`) |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## No matter what code I put in my file, Manim only renders a black frame! Why? |
| 19 | + |
| 20 | +If you are using the usual pattern to write a `Scene`, i.e., |
| 21 | +```python |
| 22 | +class MyAwesomeScene(Scene): |
| 23 | + def construct(self): |
| 24 | + ... |
| 25 | + # your animation code |
| 26 | +``` |
| 27 | +then double check whether you have spelled `construct` correctly. |
| 28 | +If the method containing your code is not called `construct` (or |
| 29 | +if you are not calling a different, custom method from `construct`), |
| 30 | +Manim will not call your method and simply output a black frame. |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## I have watched a video where a creator ran command X, but it does not work for me. Why? |
| 35 | + |
| 36 | +The video you have been watching is likely outdated. If you want to follow |
| 37 | +along, you either need to use the same version used in the video, or |
| 38 | +modify the code (in many cases it is just a method having been renamed etc.) |
| 39 | +accordingly. Check the video description, in some cases creators point out |
| 40 | +whether changes need to be applied to the code shown in the video. |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## When using `Tex` or `MathTex`, some letters are missing. How can I fix this? |
| 45 | + |
| 46 | +It is possible that you have to (re)build some fonts used by LaTeX. For |
| 47 | +some distributions, you can do this manually by running |
| 48 | +```bash |
| 49 | +fmtutil -sys --all |
| 50 | +``` |
| 51 | +We recommend consulting the documentation of your LaTeX distribution |
| 52 | +for more information. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## I want to translate some code from `manimgl` to `manim`, what do I do with `CONFIG` dictionaries? |
| 57 | + |
| 58 | +The community maintained version has dropped the use of `CONFIG` dictionaries very |
| 59 | +early, with {doc}`version v0.2.0 </changelog/0.2.0-changelog>` released in |
| 60 | +January 2021. |
| 61 | + |
| 62 | +Before that, Manim's classes basically processed `CONFIG` dictionaries |
| 63 | +by mimicking inheritance (to properly process `CONFIG` dictionaries set |
| 64 | +by parent classes) and then assigning all of the key-value-pairs in the |
| 65 | +dictionary as attributes of the corresponding object. |
| 66 | + |
| 67 | +In situations where there is not much inheritance going on, |
| 68 | +or for any custom setting, you should set these attributes yourself. |
| 69 | +For example, for an old-style `Scene` with custom attributes like |
| 70 | + |
| 71 | +```python |
| 72 | +class OldStyle(Scene): |
| 73 | + CONFIG = {"a": 1, "b": 2} |
| 74 | +``` |
| 75 | + |
| 76 | +should be written as |
| 77 | + |
| 78 | +```python |
| 79 | +class NewStyle(Scene): |
| 80 | + a = 1 |
| 81 | + b = 2 |
| 82 | +``` |
| 83 | + |
| 84 | +In situations where values should be properly inherited, the arguments |
| 85 | +should be added to the initialization function of the class. An old-style |
| 86 | +mobject `Thing` could look like |
| 87 | + |
| 88 | +```python |
| 89 | +class Thing(VMobject): |
| 90 | + CONFIG = { |
| 91 | + "stroke_color": RED, |
| 92 | + "fill_opacity": 0.7, |
| 93 | + "my_awesome_argument": 42, |
| 94 | + } |
| 95 | +``` |
| 96 | + |
| 97 | +where `stroke_color` and `fill_opacity` are arguments that concern the |
| 98 | +parent class of `Thing`, and `my_awesome_argument` is a custom argument |
| 99 | +that only concerns `Thing`. A version without `CONFIG` could look like this: |
| 100 | + |
| 101 | +```python |
| 102 | +class Thing(VMobject): |
| 103 | + def __init__( |
| 104 | + self, stroke_color=RED, fill_opacity=0.7, my_awesome_argument=42, **kwargs |
| 105 | + ): |
| 106 | + self.my_awesome_argument = my_awesome_argument |
| 107 | + super().__init__(stroke_color=stroke_color, fill_opacity=fill_opacity, **kwargs) |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## My installation does not support converting PDF to SVG, help? |
| 113 | + |
| 114 | +This is an issue with `dvisvgm`, the tool shipped with LaTeX that |
| 115 | +transforms LaTeX output to a `.svg` file that |
| 116 | +Manim can parse. |
| 117 | + |
| 118 | +First, make sure your ``dvisvgm`` version is at least 2.4 by |
| 119 | +checking the output of |
| 120 | + |
| 121 | +```bash |
| 122 | +dvisvgm --version |
| 123 | +``` |
| 124 | + |
| 125 | +If you do not know how to update `dvisvgm`, please refer to your |
| 126 | +LaTeX distributions documentation (or the documentation of your |
| 127 | +operating system, if `dvisvgm` was installed as a system package). |
| 128 | + |
| 129 | +Second, check whether your ``dvisvgm`` supports PostScript specials. This is |
| 130 | +needed to convert from PDF to SVG. Run: |
| 131 | + |
| 132 | +```bash |
| 133 | +dvisvgm -l |
| 134 | +``` |
| 135 | + |
| 136 | +If the output to this command does **not** contain `ps dvips PostScript specials`, |
| 137 | +this is a bad sign. In this case, run |
| 138 | + |
| 139 | +```bash |
| 140 | +dvisvgm -h |
| 141 | +``` |
| 142 | + |
| 143 | +If the output does **not** contain `--libgs=filename`, this means your |
| 144 | +`dvisvgm` does not currently support PostScript. You must get another binary. |
| 145 | + |
| 146 | +If, however, `--libgs=filename` appears in the help, that means that your |
| 147 | +`dvisvgm` needs the Ghostscript library to support PostScript. Search for |
| 148 | +`libgs.so` (on Linux, probably in `/usr/local/lib` or `/usr/lib`) or |
| 149 | +`gsdll32.dll` (on 32-bit Windows, probably in `C:\windows\system32`) or |
| 150 | +`gsdll64.dll` (on 64-bit Windows, also probably in `C:\windows\system32`) |
| 151 | +or `libgsl.dylib` (on MacOS, probably in `/usr/local/lib` or |
| 152 | +`/opt/local/lib`). Please look carefully, as the file might be located |
| 153 | +elsewhere, e.g. in the directory where Ghostscript is installed. |
| 154 | + |
| 155 | +When you have found the library, try (on MacOS or Linux) |
| 156 | + |
| 157 | +```bash |
| 158 | +export LIBGS=<path to your library including the file name> |
| 159 | +dvisvgm -l |
| 160 | +``` |
| 161 | + |
| 162 | +or (on Windows) |
| 163 | + |
| 164 | +```bat |
| 165 | +set LIBGS=<path to your library including the file name> |
| 166 | +dvisvgm -l |
| 167 | +``` |
| 168 | + |
| 169 | +You should now see `ps dvips PostScript specials` in the output. Refer to |
| 170 | +your operating system's documentation to find out how you can set or export the |
| 171 | +environment variable ``LIBGS`` automatically whenever you open a shell. |
| 172 | + |
| 173 | +As a last check, you can run |
| 174 | + |
| 175 | +```bash |
| 176 | +dvisvgm -V1 |
| 177 | +``` |
| 178 | + |
| 179 | +(while still having `LIBGS` set to the correct path, of course.) If `dvisvgm` |
| 180 | +can find your Ghostscript installation, it will be shown in the output together |
| 181 | +with the version number. |
| 182 | + |
| 183 | +If you do not have the necessary library on your system, please refer to your |
| 184 | +operating system's documentation to find out where you can get it and how you |
| 185 | +have to install it. |
| 186 | + |
| 187 | +If you are unable to solve your problem, check out the |
| 188 | +[dvisvgm FAQ](https://dvisvgm.de/FAQ/). |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## Where can I find more resources for learning Manim? |
| 193 | + |
| 194 | +In our [Discord server](https://manim.community/discord), we have the community maintained |
| 195 | +`#beginner-resources` channel in which links to helpful learning resources are collected. |
| 196 | +You are welcome to join our Discord and take a look yourself! If you have found some |
| 197 | +guides or tutorials yourself that are not on our list yet, feel free to add them! |
0 commit comments