messed up environment variables?

13 views
Skip to first unread message

Andrea Prestwich

unread,
Sep 24, 2025, 2:30:01 PM (4 days ago) Sep 24
to posydon-users
Hi all,

I'm just getting started with posydon and I'm getting errors running my_population.py that make me think I've messed up the environment variables. The full error is appended below. The crucial "missing" file is:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/posydon/visualization/posydon.mplstyle'


The file the code is looking appears to be 

/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/visualization/posydon.mplstyle


(just one "posydon" in the path)

The environment variables are set as follows

>>> import posydon

>>> print(posydon.__file__)

/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/__init__.py

>>> 

(posydon_env) aprestwi@gs66-chandra TestPop % printenv PATH_TO_POSYDON

/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/

(posydon_env) aprestwi@gs66-chandra TestPop % printenv PATH_TO_POSYDON_DATA

/Users/aprestwi/Documents/posydon/data

(posydon_env) aprestwi@gs66-chandra TestPop % 


Any suggestions for sorting this out much appreciated!

- Andrea Prestwich

(posydon_env) aprestwi@gs66-chandra TestPop % python my_population.py

Traceback (most recent call last):

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/matplotlib/style/core.py", line 137, in use

    style = _rc_params_in_file(style)

            ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/matplotlib/__init__.py", line 870, in _rc_params_in_file

    with _open_file_or_url(fname) as fd:

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/contextlib.py", line 137, in __enter__

    return next(self.gen)

           ^^^^^^^^^^^^^^

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/matplotlib/__init__.py", line 847, in _open_file_or_url

    with open(fname, encoding='utf-8') as f:

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

FileNotFoundError: [Errno 2] No such file or directory: '/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/posydon/visualization/posydon.mplstyle'


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/Users/aprestwi/Documents/posydon/TestPop/my_population.py", line 1, in <module>

    from posydon.popsyn.synthetic_population import PopulationRunner

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/popsyn/synthetic_population.py", line 44, in <module>

    import posydon.visualization.plot_pop as plot_pop

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/visualization/plot_pop.py", line 19, in <module>

    plt.style.use(os.path.join(PATH_TO_POSYDON, "posydon/visualization/posydon.mplstyle"))

  File "/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/matplotlib/style/core.py", line 139, in use

    raise OSError(

OSError: '/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/posydon/visualization/posydon.mplstyle' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)

(posydon_env) aprestwi@gs66-chandra TestPop % 


Seth Gossage

unread,
Sep 24, 2025, 3:04:35 PM (4 days ago) Sep 24
to posydon-users
Hi Amanda, 

Could you please try setting the PATH_TO_POSYDON environment variable as /Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages instead? The path should point to the parent directory of the `posydon` directory, which isn't fully clear from our documentation in the case of a conda install, so we'll improve that.

Andrea Prestwich

unread,
Sep 24, 2025, 4:10:06 PM (4 days ago) Sep 24
to posydon-users
Thanks for your rapid response, Seth! I really appreciate it.

If I really force the issue, I can get my_population to run: 

poprun = PopulationRunner('/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/posydon/popsyn/population_params_default.ini', verbose=True)

I get a file 1e+00_Zsun_population.h5. 

However, the environment variables are still messed somehow. If I use $PATH_TO_POSYDON instead of spelling out the complete path:

poprun = PopulationRunner('$PATH_TO_POSYDON/posydon/popsyn/population_params_default.ini', verbose=True)

I get the following:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/aprestwi/Documents/posydon/TestPop/$PATH_TO_POSYDON/posydon/popsyn/population_params_default.ini'


sanity check on the variables:

(posydon_env) aprestwi@gs66-chandra TestPop % printenv PATH_TO_POSYDON_DATA

/Users/aprestwi/Documents/posydon/data

(posydon_env) aprestwi@gs66-chandra TestPop % printenv PATH_TO_POSYDON     

/Users/aprestwi/miniforge3/envs/posydon_env/lib/python3.11/site-packages/



Thanks again for any suggestions....

Seth Gossage

unread,
Sep 24, 2025, 5:47:16 PM (4 days ago) Sep 24
to posydon-users

Hmm, just to check, what about if instead of  poprun = PopulationRunner('$PATH_TO_POSYDON/posydon/popsyn/population_params_default.ini'verbose=True), you use 

```
import os
POSYDON_DIR = os.getenv("PATH_TO_POSYDON")

poprun = PopulationRunner(os.path.join(POSYDON_DIR, "posydon/popsyn/population_params_default.ini"))
```
instead? Normally you have to load in the environment variable with something like `os.getenv()` in Python or a Jupyter notebook, depending on the environment that you are running in.
Reply all
Reply to author
Forward
0 new messages