Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manim working in Terminal, but extension can't find ffmpeg #98

Open
rrizkylubis opened this issue Aug 25, 2024 · 7 comments
Open

Manim working in Terminal, but extension can't find ffmpeg #98

rrizkylubis opened this issue Aug 25, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@rrizkylubis
Copy link

Hi,

I installed manim to a conda environment on my Mac. I activated the environment and ran it with success:

Last login: Sun Aug 25 10:37:06 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) Rizkys-Macbook-Air:~ rizkylubis$ conda activate manim-env
(manim-env) Rizkys-Macbook-Air:~ rizkylubis$ manim -pql /Users/rizkylubis/Documents/Coding_Projects/manim_test.py
Manim Community v0.18.1

[08/25/24 10:40:26] INFO     Animation 0 : Using cached     cairo_renderer.py:88
                             data (hash :                                       
                             1185818338_468798911_223132457                     
                             )                                                  
                    INFO     Animation 1 : Using cached     cairo_renderer.py:88
                             data (hash :                                       
                             624642324_1772076266_325649555                     
                             8)                                                 
                    INFO     Animation 2 : Using cached     cairo_renderer.py:88
                             data (hash :                                       
                             624642324_1733944848_285462960                     
                             9)                                                 
                    INFO     Combining to Movie file.   scene_file_writer.py:617
                    INFO                                scene_file_writer.py:737
                             File ready at                                      
                             '/Users/rizkylubis/media/v                         
                             ideos/manim_test/480p15/Sq                         
                             uareToCircle.mp4'                                  
                                                                                
                    INFO     Rendered SquareToCircle                scene.py:247
                             Played 3 animations                                
                    INFO     Previewed File at:                  file_ops.py:231
                             '/Users/rizkylubis/media/videos/man                
                             im_test/480p15/SquareToCircle.mp4'                 
(manim-env) Rizkys-Macbook-Air:~ rizkylubis$ 

I opened the manim_test.py file in VS Code, changed the python interpreter to my manim-env. When I run the Manim Sideview extension I get this:

Manim Extension XTerm
Serves as a terminal for logging purpose.

Extension Version 0.2.13

MSV /Users/rizkylubis/Documents/Coding_Projects>"/opt/anaconda3/envs/manim-env/bin/manim" "/Users/rizkylubis/Documents/Coding_Projects/manim_test.py" SquareToCircle
/opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Manim Community v0.18.1

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/cli/render/ │
│ commands.py:119 in render                                                    │
│                                                                              │
│   116 │   │   for SceneClass in scene_classes_from_file(file):               │
│   117 │   │   │   try:                                                       │
│   118 │   │   │   │   with tempconfig({}):                                   │
│ ❱ 119 │   │   │   │   │   scene = SceneClass()                               │
│   120 │   │   │   │   │   scene.render()                                     │
│   121 │   │   │   except Exception:                                          │
│   122 │   │   │   │   error_console.print_exception()                        │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/scene/scene │
│ .py:147 in __init__                                                          │
│                                                                              │
│    144 │   │   │   )                                                         │
│    145 │   │   else:                                                         │
│    146 │   │   │   self.renderer = renderer                                  │
│ ❱  147 │   │   self.renderer.init_scene(self)                                │
│    148 │   │                                                                 │
│    149 │   │   self.mobjects = []                                            │
│    150 │   │   # TODO, remove need for foreground mobjects                   │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/renderer/ca │
│ iro_renderer.py:54 in init_scene                                             │
│                                                                              │
│    51 │   │   self.static_image = None                                       │
│    52 │                                                                      │
│    53 │   def init_scene(self, scene):                                       │
│ ❱  54 │   │   self.file_writer: Any = self._file_writer_class(               │
│    55 │   │   │   self,                                                      │
│    56 │   │   │   scene.__class__.__name__,                                  │
│    57 │   │   )                                                              │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/scene/scene │
│ _file_writer.py:88 in __init__                                               │
│                                                                              │
│    85 │   │   )                                                              │
│    86 │   │   # fail fast if ffmpeg is not found                             │
│    87 │   │   if not ensure_executable(Path(config.ffmpeg_executable)):      │
│ ❱  88 │   │   │   raise RuntimeError(                                        │
│    89 │   │   │   │   "Manim could not find ffmpeg, which is required for ge │
│    90 │   │   │   │   "For installing ffmpeg please consult https://docs.man │
│    91 │   │   │   │   "Make sure to either add ffmpeg to the PATH environmen │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Manim could not find ffmpeg, which is required for generating 
video output.
For installing ffmpeg please consult 
https://docs.manim.community/en/stable/installation.html
Make sure to either add ffmpeg to the PATH environment variable
or set path to the ffmpeg executable under the ffmpeg header in Manim's 
configuration.
[34454] Execution returned code=1 in 1.301 seconds returned signal null 

(manim-env) /Users/rizkylubis/Documents/Coding_Projects/>

I have to say I am very new to coding, so am not quite sure what to do.

@lbirkert
Copy link
Contributor

Hey, it might be that your environment differs when running manim via ZSH compared to via the extension (Although I don't know which bash the extension even uses). It might be that the extension tries to run manim via bash, which looks for a ~/.bashrc, which doesn't contain an export PATH="/path/to/ffmpeg/bin:$PATH", while zsh looks for a ~/.zshrc, which contains this line.

To fix this you might wanna try what it suggests:

Make sure to either add ffmpeg to the PATH environment variable
or set path to the ffmpeg executable under the ffmpeg header in Manim's 
configuration.

There should be a way to do the second one, although I am not exactly the most familiar with Manim and its configuration. I don't know whether the first one is possible, depends on the current implementation and how the extension starts Manim.

@Rickaym could you please provide further clarification?

@Rickaym
Copy link
Owner

Rickaym commented Oct 30, 2024

Have you installed FFMPEG correctly?

@Rickaym Rickaym closed this as completed Oct 30, 2024
@rrizkylubis
Copy link
Author

@Rickaym
ffmpeg is installed correctly. Using the VS Code integrated terminal this is what I get:

(manim-env) rizkylubis@Rizkys-Macbook-Air Manim % which manim
/opt/anaconda3/envs/manim-env/bin/manim
(manim-env) rizkylubis@Rizkys-Macbook-Air Manim % which ffmpeg
/opt/anaconda3/envs/manim-env/bin/ffmpeg
(manim-env) rizkylubis@Rizkys-Macbook-Air Manim % echo $PATH | tr ':' '\n'
/opt/anaconda3/envs/manim-env/bin
/Users/rizkylubis/Documents/Coding_Projects/anki_to_obsidian/dist/anki_CLI
/opt/anaconda3/envs/manim-env/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/opt/anaconda3/envs/manim-env/bin
/Users/rizkylubis/Documents/Coding_Projects/anki_to_obsidian/dist/anki_CLI
/opt/anaconda3/condabin
/Library/Frameworks/Python.framework/Versions/3.11/bin

However Manim Sideview appears to detect the conda environment but not inherit the path environment variables set by the environment. While I could manually add ffmpeg from the conda environment to the path, I really don't want to do this, the extension should inherit any path environment variables set by the environment I am in.

Manim Extension XTerm
Serves as a terminal for logging purpose.

Extension Version 0.2.15

MSV /Users/rizkylubis/Documents/Coding_Projects/Manim>"/opt/anaconda3/envs/manim-env/bin/manim" "/Users/rizkylubis/Documents/Coding_Projects/Manim/manim_test.py" SquareToCircle
/opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Manim Community v0.18.1

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/cli/render/ │
│ commands.py:119 in render                                                    │
│                                                                              │
│   116 │   │   for SceneClass in scene_classes_from_file(file):               │
│   117 │   │   │   try:                                                       │
│   118 │   │   │   │   with tempconfig({}):                                   │
│ ❱ 119 │   │   │   │   │   scene = SceneClass()                               │
│   120 │   │   │   │   │   scene.render()                                     │
│   121 │   │   │   except Exception:                                          │
│   122 │   │   │   │   error_console.print_exception()                        │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/scene/scene │
│ .py:147 in __init__                                                          │
│                                                                              │
│    144 │   │   │   )                                                         │
│    145 │   │   else:                                                         │
│    146 │   │   │   self.renderer = renderer                                  │
│ ❱  147 │   │   self.renderer.init_scene(self)                                │
│    148 │   │                                                                 │
│    149 │   │   self.mobjects = []                                            │
│    150 │   │   # TODO, remove need for foreground mobjects                   │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/renderer/ca │
│ iro_renderer.py:54 in init_scene                                             │
│                                                                              │
│    51 │   │   self.static_image = None                                       │
│    52 │                                                                      │
│    53 │   def init_scene(self, scene):                                       │
│ ❱  54 │   │   self.file_writer: Any = self._file_writer_class(               │
│    55 │   │   │   self,                                                      │
│    56 │   │   │   scene.__class__.__name__,                                  │
│    57 │   │   )                                                              │
│                                                                              │
│ /opt/anaconda3/envs/manim-env/lib/python3.10/site-packages/manim/scene/scene │
│ _file_writer.py:88 in __init__                                               │
│                                                                              │
│    85 │   │   )                                                              │
│    86 │   │   # fail fast if ffmpeg is not found                             │
│    87 │   │   if not ensure_executable(Path(config.ffmpeg_executable)):      │
│ ❱  88 │   │   │   raise RuntimeError(                                        │
│    89 │   │   │   │   "Manim could not find ffmpeg, which is required for ge │
│    90 │   │   │   │   "For installing ffmpeg please consult https://docs.man │
│    91 │   │   │   │   "Make sure to either add ffmpeg to the PATH environmen │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Manim could not find ffmpeg, which is required for generating 
video output.
For installing ffmpeg please consult 
https://docs.manim.community/en/stable/installation.html
Make sure to either add ffmpeg to the PATH environment variable
or set path to the ffmpeg executable under the ffmpeg header in Manim's 
configuration.
[20859] Execution returned code=1 in 0.485 seconds returned signal null 

(manim-env) /Users/rizkylubis/Documents/Coding_Projects/Manim/>echo $PATH | tr ':' '\n'
/Users/rizkylubis/Documents/Coding_Projects/anki_to_obsidian/dist/anki_CLI
/opt/anaconda3/condabin
/Library/Frameworks/Python.framework/Versions/3.11/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin

@Rickaym Rickaym reopened this Oct 30, 2024
@Rickaym
Copy link
Owner

Rickaym commented Oct 30, 2024

Interesting. So it looks like the venv is being set properly, just that it's not picking up FFMPEG. I'll try on my side.

comment ref: https://www.youtube.com/watch?v=sFpFlMEu7OY&lc=UgwAf8EysGh04b5OTZl4AaABAg

@lbirkert
Copy link
Contributor

It might be that the environment variables are shell specific. You seem to be using zsh. Could you paste your ~/.zshrc?

@rrizkylubis
Copy link
Author

While it looks like I am using zsh in the beginning I am actually using bash, in both the terminal app and the VS Code Integrated terminal:

Terminal app:

Last login: Tue Oct 29 20:15:48 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Rizkys-Macbook-Air:~ rizkylubis$ echo $SHELL
/bin/bash
Rizkys-Macbook-Air:~ rizkylubis$ 

VS Code integrated terminal:

(manim-env) rizkylubis@Rizkys-Macbook-Air Manim % echo $SHELL
/bin/bash
(manim-env) rizkylubis@Rizkys-Macbook-Air Manim % 

I will include both the ~/.zshrc and ~/.bash_profile below:

~/.zshrc



# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export PATH="/Users/rizkylubis/Documents/Coding_Projects/anki_to_obsidian/dist/anki_CLI:$PATH"

~/.bash_profile


# Setting PATH for Python 3.11
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
export PATH


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

#Path for anki_CLI
export PATH="/Users/rizkylubis/Documents/Coding_Projects/anki_to_obsidian/dist/anki_CLI:$PATH"

@Rickaym Rickaym self-assigned this Nov 6, 2024
@Rickaym Rickaym added the bug Something isn't working label Nov 6, 2024
@niemiaszek
Copy link

Same problem using Pixi instead of Conda, although I believe the mechanism is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants