Re: [spyder] In Spyder, Python doesn't find some external programs (ffmeg) (Pb with PATH ?)

1,629 views
Skip to first unread message

Carlos Córdoba

unread,
Mar 5, 2013, 11:59:01 AM3/5/13
to spyd...@googlegroups.com
Hi Laurent,

I don't know what could be happening. I opened Issue 1298 so we don't
forget to solve the problem for the next release.

Cheers,
Carlos

El 01/03/13 07:04, Laurent PARISE escribió:
> Excuse me for my English first.
>
> I use Mac OS 10.6.8 Spyder for some time with great pleasure. Thank
> you for your work!
> However, since yesterday I have a problem with creating animations
> (MP4) with matplotlib.
>
> 1. My script works from the command line (and make an mp4 file), but I
> get an error in Spyder with the same script:
>
> /Applications/Spyder.app/Contents/Resources/lib/python2.7/matplotlib/animation.py:
> 598:
> UserWarning: ffmpeg MovieWriter unavailable
> warnings.warn ("% s MovieWriter unavailable" writer%)
>
> It seems that Spyder's Python can not find the'ffmpeg' program that
> creates the MP4 file.
>
> 2. I did some tests: if I start Spyder in the console command line, my
> script is compiled correctly in Spyder ! But if I start Spyder by
> clicking on the icon in the Applications folder, python does not find
> 'ffmpeg' that isin '/usr/local/bin'.
>
> In fact, '/usr/local/bin' is in myPATH in the console (I type 'env' in
> the console to see it), but Spyder do not know if I run it from the
> Applications folder...
>
> Could you tell me if it is possible to tell Spyder, it must use the
> PATH variable to launch external programs (if my problem is it)?
>
>
> Thanks again.
> Laurent.
>
> --
> You received this message because you are subscribed to the Google
> Groups "spyder" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to spyderlib+...@googlegroups.com.
> To post to this group, send email to spyd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/spyderlib?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

mrclary

unread,
Mar 5, 2013, 1:21:59 PM3/5/13
to spyd...@googlegroups.com
If I understand your problem correctly:
1. you have the executable path /usr/local/bin/ffmpeg
2. your script executes successfully if run in a python (or ipython) interpreter started from the terminal
3. your script executes unsuccessfully if run from within Spyder (standalone app)

If the above is correct, then I think I know what the problem is.
When Spyder is started, the interpreter inherits the following system PATH:

In[6]: os.environ['PATH']
Out[6]: '/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Spyder.app/Contents/Resources'

which does not include '/usr/local/bin'

I have run into this problem before and found one solution is to modify the system path in the interpreter's startup script. I've attached the startup script that I use. The script captures the environment variables from a standard terminal session, including any statements contained in your bash profile scripts. On my system I use ~/.profile and /etc/profile for my bash profiles, but if you use something else (e.g. bashrc, bash_profile, etc.) you will want to modify the attached script appropriately. In Spyder's preferences, specify the attached script as the startup script.

Your system path (os.environ['PATH']) in Spyder should now match your PATH environment variable in a Terminal session (echo $PATH), and scripts run from within Spyder should be able to find any executables in '/usr/local/bin'.

Ryan Clary

On Friday, March 1, 2013 4:04:53 AM UTC-8, Laurent PARISE wrote:
Excuse me for my English first.

I use
Mac OS 10.6.8 Spyder for some time with great pleasure. Thank you for your work!
However, since yesterday I have a problem with creating animations (MP4) with matplotlib.

1. My
script works from the command line (and make an mp4 file), but I get an error in Spyder with the same script:

/Applications/Spyder.app/Contents/Resources/lib/python2.7/matplotlib/animation.py: 598:
UserWarning: ffmpeg MovieWriter unavailable
warnings.warn ("% s MovieWriter unavailable" writer%)

It seems that Spyder's Python can not find the 'ffmpeg' program that creates the MP4 file.

2. I did some tests: if I start Spyder in the console command line, my script is compiled correctly in Spyder ! But if I start Spyder by clicking on the icon in the Applications folder, python does not find 'ffmpeg' that is in '/usr/local/bin'.

In fact, '/usr/local/bin' is in my PATH in the console (I type 'env' in the console to see it), but Spyder do not know if I run it from the Applications folder ...
spyder_ipython_startup.py

Laurent PARISE

unread,
Mar 16, 2013, 11:33:29 AM3/16/13
to spyd...@googlegroups.com
Thanks a lot for your answer. Sorry for my late reply, I was away for several days.
 
If I understand your problem correctly:
1. you have the executable path /usr/local/bin/ffmpeg
2. your script executes successfully if run in a python (or ipython) interpreter started from the terminal
3. your script executes unsuccessfully if run from within Spyder (standalone app)

You're right : It happens exactly 1, 2 and 3, but I would add that if I run Spyder from a terminal (and not from the "Applications" menu)
by typing "/Applications/Spyder.app/Contents/MacOS/Spyder", Spyder then recognizes the paths that are in the PATH variable and ffmpeg starts correctly when called by Matplotlib.

Laurent.

Carlos Córdoba

unread,
Mar 25, 2013, 12:20:34 AM3/25/13
to spyd...@googlegroups.com
Hi Ryan,

Thanks a lot for your script, it made my day. Just yesterday I wasted a couple of hours trying to find a way to add environment variables to our app.

I really missed your code the first time but now I added it (with due credit of course) to our tree.

Thanks again,
Carlos

El 05/03/13 13:21, mrclary escribió:

Han ZHANG

unread,
Nov 18, 2014, 12:22:25 AM11/18/14
to spyd...@googlegroups.com
Come into the same problem. Where can I find the interpreter's startup script? Or which directory should I put your file into? Thanks

Best
Han

在 2013年3月5日星期二UTC-5下午1时21分59秒,mrclary写道:

Ryan Clary

unread,
Nov 18, 2014, 3:59:56 PM11/18/14
to spyd...@googlegroups.com
It doesn't matter where you put the script. But in Spyder's preferences >> console >> advanced settings, select "use the following startup script" and specify the file.

Thanks,
Ryan Clary
Reply all
Reply to author
Forward
0 new messages