1

I intend to run some R Animation demo code but this error message returns

Warning messages:
1: In im.convert(img.files, output = movie.name, convert = convert,  :
  Please install ImageMagick first or put its bin path into the system PATH variable

I've downloaded ImageMagic for mac. It's a folder with subfolders like bin, lib, share etc. How can put its bin path into system path? Thanks.

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
santoku
  • 3,297
  • 7
  • 48
  • 76

2 Answers2

2

Option 1:

Put something like

PATH=$PATH:blablabla/ImageMagic/bin

in ~/.bashrc file.

  • $PATH is the original PATH variable;
  • : is used to separate different candidates;
  • the final blablabla/ImageMagic/bin denotes the path to the executable.

Whenever you open up a new terminal, ~/.bashrc file will be run, hence environmental variable PATH will be set as above. If you start up your R from terminal, this should do the work.

Option 2:

If you normally invoke R by clicking its icon, then ~/.bashrc may not work. In this case, use the ~/.profile file instead. This is run whenever you log in. Add the following to the bottom of this file:

export PATH=$PATH:blablabla/ImageMagic/bin

(Note export here. You may need to log out and log in again so that the setting takes effect.)


Comments

  • Both ~/.bashrc and ~/.profile are hidden files. You may use ls -a ~ to see them. To edit/save them, use the normal text editor.
  • The link @Gregor gives, suggests using ~/.bash_profile. Well, These days this file is normally replaced by ~/.profile. But you should use ls -a ~ to check.

follow up:

OK, so you have .bash_profile instead of .profile on your machine.

To open this file, do:

sudo nano ~/.bash_profile

Then move to the bottom, and add the line you need:

export PATH=$PATH:blablabla/ImageMagic/bin

To save edit, do ctrl + O (maybe hitting an ENTER as well); then you quit editor by ctrl + X.

If you do not want to log out and log in again to let new setting take effect, try:

source ~/.bash_profile
Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
  • thank you for answering. I normally click its icon, so option 2. in terminal when I run ls -a ~ I could see .bash_history .bash_profile .bash_profile.pysave .bash_sessions what should I do next and how can I open bash-profile? – santoku Jun 05 '16 at 01:58
  • I'm quite useless in terminal. I tried this and it doesn't open the bash file: subl ~/.bash_profile – santoku Jun 05 '16 at 02:03
  • thanks, that does work, but i notice that export line seems to be for python though. These are the last few lines after sudo nano: # Setting PATH for Python 3.5 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}" export PATH – santoku Jun 05 '16 at 02:07
  • after adding the line i tried both ctrl+o and ctrl+x to save it, but it doesn't seem to get saved and nothing happens – santoku Jun 05 '16 at 02:14
  • right, it stayed in the same page instead of exit nano editor after ctrl+x – santoku Jun 05 '16 at 02:18
  • ur advice is awesome! so that line added, I pointed the path to download as ImageMagick is there now export PATH=$PATH:Downloads/ImageMagic/bin but still same error msg in R after trying both source ~/.bash_profile and log out log in – santoku Jun 05 '16 at 02:45
1

I had the same problem with Windows a few weeks ago. I don't know if it is the same on Mac or not, but it is worth a try.

When you go to download ImageMagick there should be a prompt that says something like "select additional tasks." Be sure to check "Install Legacy Utilities (e.g. convert)." I think they changed the names of a few things between versions. That selection names things properly for R. Also, if this happens to be the same issue I had (maybe, maybe not) be sure to restart R before trying again after you've downloaded it.

Bryan Goggin
  • 2,449
  • 15
  • 17