Running Pythia8 with ROOT getting fatal error: 'Pythia8/Pythia.h' file not found

_ROOT Version:5.34.36
Platform: MacOS 10.12
Compiler: Not Provided

Hello everyone,

after browsing relevant posts, I still cannot figure out how to solve my problem, so please help me! I will appreciate your time very much.

I am trying to run a macro which makes uses of pythia8, (this macro is not written by myself, so I am still figuring out how to run it). I have installed ROOT a long time ago and I just installed PYTHIA 8 today with the instruction under a subfolder of the ROOT folder. Then when I try to run the macro I got this line of error message:

/bin/sh: pythia8-config: command not found

forWong_main.cpp:1:10: fatal error: ‘Pythia8/Pythia.h’ file not found

#include “Pythia8/Pythia.h”


1 error generated.

make: *** [main] Error 1

I have read posts relevant to this error and tried to enable the shared library option of PYTHIA (I am not sure if I did it successfully and when I install PYTHIA8 for the first time I didn’t enable this option). I also saw comments that I should install PYTHIA first and then install ROOT, which is not what I want to try unless there is no other way. I am not sure what my problem is. Please help me!!

Thank you for reading this!

That means you should add the pythia8243/bin directory (the directory where you installed Pythia8) in your PATH. You should also set the PYTHIA8DATA environment variable, as described in the README file of Pythia8

Did you mean add pythia8243/bin directory in my PATH like this:

int main(int argc, char* argv[]) {

Pythia pythia("/usr/local/pythia8243");


This is the file I am trying to run and I added the path like this. Please let me know if I did it wrong, I am not sure what PATH is, sorry!

And I did this according to README, I added this to a file called found using “search”:
export PYTHIA8DATA=/usr/local/pythia8243/share/Pythia8/xmldoc

I am not sure if I set the environment variable correctly. Probably not, because I still get the same error when I type “make” under the code directory. I am sorry, I tried to look up how to set up environment variable, but I am still not sure how to do it correctly. Can you please be more specific about add directory in PATH and setting environment variables?

Thank you!

1 Like

I mean add /usr/local/pythia8243/bin to your PATH (e.g. in your bashrc), something like:

export PATH=${PATH}:/usr/local/pythia8243/bin
1 Like

Thank you!! I am not getting that error, but I got a new one:

ld: warning: directory not found for option ‘-L/usr/local/pythia8243/lib’

ld: library not found for -lpythia8

How did you install Pythia? What file are in /usr/local/pythia8243/lib?

The error is gone and I can compile it now! Sorry, I had the previous error because I didn’t run "make " command for pythia8.

But when I want to run my code, I got this error message:

./forWong forWong.cmnd > forWong.out
dyld: Library not loaded: @rpath/libpythia8.dylib
Referenced from: /usr/local/root/Summer/forWong/./forWong
Reason: image not found
/bin/sh: line 1: 41182 Abort trap: 6 ./forWong forWong.cmnd > forWong.out
make: *** [run] Error 134

And MacOs send me this:
forWong cannot be opened because of a problem.
Check with the developer to make sure forWong works with this version of macOS. You may need to reinstall the application. Be sure to install any available updates for the application and macOS.

Click Report to see more detailed information and send a report to Apple.

Do you know how I can resolve this? Thank you so much for your help!!

I’m not a MacOS user, but maybe adding /usr/local/pythia8243/lib to DYLD_LIBRARY_PATH could help

export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/pythia8243/lib

I added this line to and I also ran this command in my terminal but I am getting the same error. Did I do this correctly?

I guess so… Where is the libpythia8.dylib file?

This is the where libpythia8.dylib is. You gave me the correct one.

Could you try to add also this:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/pythia8243/lib

I tried, and I still got the same error.:cold_sweat:

Did you run the bashrc after modifying it?

No…How do I run it? :hot_face:

source /wherevever/is/bashrc

And replace /wherevever/is/ by the location of your bashrc script :wink:

I look at where the is and I think it’s probably not the right file because the location is related to python???.. Here is the location: /anaconda3/pkgs/pexpect-4.6.0-py37_0/lib/python3.7/site-packages/pexpect

Is there any other name the bashrc file could be called?

Sorry I should have realized this earlier!

There should be a file called .bashrc in your $HOME directory I suppose…

I didn’t see anything called .bashrc in my home directory:cold_sweat:

OK, so maybe a MacOS user could help you more… @Axel, could you help?