Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R EnvironmentError: Could not find Ghostscript on path. RWebLogo

I ran into an odd issue that I cannot fix in any way and I was hoping someone here may have a better understanding of whats wrong;

I am unable to use RWebLogo package - even run the simplest examples due to the same missing Ghostscript error.

e.g. running:

library(RWebLogo)
aln <- c('CCAACCCAA', 'CCAACCCTA', 'AAAGCCTGA', 'TGAACCGGA')
weblogo(seqs=aln, file.out='mylogo.pdf')

Throws this error:

Traceback (most recent call last):
  File "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RWebLogo/extdata/weblogo-3.3/weblogo", line 71, in <module>
    weblogolib._cli.main()
  File "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RWebLogo/extdata/weblogo-3.3/weblogolib/_cli.py", line 82, in main
    formatter(data, format, opts.fout)
  File "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RWebLogo/extdata/weblogo-3.3/weblogolib/__init__.py", line 757, in pdf_formatter
    gs = GhostscriptAPI()    
  File "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RWebLogo/extdata/weblogo-3.3/weblogolib/__init__.py", line 196, in __init__
    raise EnvironmentError("Could not find Ghostscript on path."
EnvironmentError: Could not find Ghostscript on path. There should be either a gs executable or a gswin32c.exe on your system's path

I have installed ghostscript ver 9.15 with configure/make/install in the terminal and then added the PATH to bash profile and executed it. When I run gs in the terminal it works, confirming it is set to the system path, yet the same error still occurs. Even after rebooting.

I tried adding the gs to the environment in R directly:

Sys.setenv(R_GSCMD = "/Applications/ghostscript-9.15/bin/gs")

which also hasn't helped... Gives exactly the same error. When I search the R environment it shows that gs is there.

Important version information:

MAC: OS Yosemite 10.10.1;
R version 3.1.1 (2014-07-10);
Platform: x86_64-apple-darwin10.8.0 (64-bit); 
RWebLogo_1.0.3

Do you know of any issue that may have cause this problem? I'm new to programming, so I am worried I may be missing something basic. I would be grateful for any advice. Thank you!

like image 213
alexo4 Avatar asked Oct 19 '22 19:10

alexo4


1 Answers

I have gotten in touch with Omar, the author of RWebLogo, and he has been really helpful in pinpointing my problems and resolving the issue.

First, he advised to run the RWebLogo on a test sequence on the terminal: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/RWebLogo/extdata/weblogo-3.3/weblogo -f test_seqs.txt -o ~/Desktop/out.pdf -F pdf

Change the base directory (everything before extdata/weblogo …) of the script above to be whatever the command below gives you in R:

system.file(package = 'RWebLogo')

I ran it and got a new error: the lack of numpy. I actually had the numpy installed but without full user privileges. After reinstalling numpy, the RWebLogo was successfully running from the terminal.

Still, the RStudio was throwing a GhostScript error. Omar suggested that there is a problem with an older version of RStudio running on Yosemite (I currently have 10.10.1), and sent me a link to an updated RStudio version where the problem was fixed.

http://www.r-bloggers.com/r-and-rstudio-incompatibility-with-yosemite-mac-os-x-10-10/

I got the updated RStudio and everything works great there right now. Hope this helps someone with a similar issue!

like image 169
alexo4 Avatar answered Oct 22 '22 22:10

alexo4