PyROOT and PyCharm

Hi everyone,

Do anybody uses PyCharm with ROOT? I’m trying to make them work together but there is still

ROOT and python are installed via Homebrew, ROOT importing is working in terminal python, PyCharm uses the same interpreter as the terminal python, default PyCharm shell is bash and ~/.bash_profile contains

Has anybody faced this problem and solved it? Or any other ideas how to make it work?

OS version: El Capitan 10.11.3, ROOT version: 5.34.34

1 Like

Hi,

is the PYTHONPATH correctly set from within the IDE?
And the PATH? (os.system(“root -q”) to test this)

Cheers,
Danilo

Thank you ))
I added
/usr/local/Cellar/root/5.34.34_1/lib/root
to the Project Structure and it worked.

[quote=“dpiparo”]Hi,

is the PYTHONPATH correctly set from within the IDE?
And the PATH? (os.system(“root -q”) to test this)

Cheers,
Danilo[/quote]

i use pycharm, conda with root. Adding root to the project structure is not a very good way to do it.

To make root available to pycharm, you need to make pycharm see both the root’s python modules (under $ROOTSYS/lib/.py), as well as the root’s libraries (under $ROOTSYS/lib/.so").

To achieve these you need to set both the project path, and the LD_LIBRARY_PATH env for pycharm, respectively.

To do the first part, check out this link:
http://stackoverflow.com/questions/24197970/pycharm-import-external-library

To do the second part, open up the pycharm start up script. for me it is under

$PYCHARM_INSTALLATION_DIR/bin/pycharm.sh

it is a shell script, not the python wrapper on top it (which also named pycharm.sh)

add the needed env variables in the shell script, my script for pyroot looks like this:

#!/bin/sh
#
# ---------------------------------------------------------------------
# PyCharm startup script.
# ---------------------------------------------------------------------
#

# ROOT env
export ROOTSYS=/usr/local/root
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
export PYTHONPATH=$PYTHONPATH:$ROOTSYS/lib
export PYTHONSTARTUP=$HOME/.pythonstartup

message()
{
  TITLE="Cannot start PyCharm"
  ...

Hi i have a ubuntu 18.04 I install pycharm CE with appstore of ubuntu and I can not change my pycharm.sh (which is in read only in /snap/… ) Can you help me I am new in this kind of things

pierre you can always copy the shell script to your $HOME, make changes, and execute your local script instead of the one under /snap