Skip to content

Can't install pyradex on latest (and any) anaconda  #24

@SmirnGreg

Description

@SmirnGreg

Dear Adam,

I can't install pyradex and make it to go through tests. I am installing it into conda environment since I don't have root access on most machines.

Steps to reproduce:

conda create -n pyradex_demo anaconda python=3.7
conda activate pyradex_demo      
git clone --recursive https://github.com/keflavich/pyradex.git
cd pyradex
pip install astroquery
pip install https://github.com/astropy/specutils/archive/master.zip
python setup.py install_radex install_myradex install

python runtests.py  # raises   File "_pytest.config", line 187, in addini AssertionError
pytest # raises Failed: [pytest] section in setup.cfg files is no longer supported, change to [tool:pytest] instead.

rm setup.cfg        
pytest   
# ==================================== test session starts ====================================
#platform linux -- Python 3.7.3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
#rootdir: /home/smirnov/pyradex, inifile:
#plugins: remotedata-0.3.1, openfiles-0.3.2, doctestplus-0.3.0, arraydiff-0.3
#collected 22 items                                                                          

#pyradex/tests/test_fjdu.py FF                                                         [  9%]
#pyradex/tests/test_radex.py .FF......F..F..F                                          [ 81%]
#pyradex/tests/test_radex_install.py F                                                 [ 86%]
#pyradex/tests/test_radex_myradex_consistency.py FF                                    [ 95%]
#pyradex/tests/test_synthspec.py

ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyradex 
   ...: import numpy as np 
   ...: R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co'
   ...: , temperature=20) 
   ...: Tlvg = R(escapeProbGeom='lvg') 
   ...: Tslab = R(escapeProbGeom='slab') 
   ...: Tsphere = R(escapeProbGeom='sphere') 
   ...: Tlvg[:3].pprint() 
   ...: Tslab[:3].pprint() 
   ...: Tsphere[:3].pprint()                                                                 
/home/smirnov/pyradex/pyradex/core.py:910: RuntimeWarning: invalid value encountered in true_divide
  frac_level_diff = level_diff/self.level_population
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0

This looks very different from what is in the readme, and started to work only after I have installed RADEX from https://personal.sron.nl/~vdtak/radex/index.shtml

Before that, and on other machine without RADEX, I get the following:

Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pyradex
   ...: import numpy as np
   ...: R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co', temperature=20)
   ...: Tlvg = R(escapeProbGeom='lvg')
   ...: Tslab = R(escapeProbGeom='slab')
   ...: Tsphere = R(escapeProbGeom='sphere')
   ...: Tlvg[:3].pprint()
   ...: Tslab[:3].pprint()
   ...: Tsphere[:3].pprint()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-5897764a5c29> in <module>
      1 import pyradex
      2 import numpy as np
----> 3 R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co', temperature=20)
      4 Tlvg = R(escapeProbGeom='lvg')
      5 Tslab = R(escapeProbGeom='slab')

~/pyradex/pyradex/core.py in __init__(self, collider_densities, density, total_density, temperature, species, column, column_per_bin, tbackground, deltav, abundance, datapath, escapeProbGeom, outfile, logfile, debug, mu, source_area)
    290                 raise ValueError("Data path %s was not successfully stored;"
    291                                  " instead %s was." % (datapath,self.datapath))
--> 292         self.species = species
    293         if self.molpath == b'':
    294             raise ValueError("Must set a species name.")

~/pyradex/pyradex/base_class.py in species(self, species)
    125         self._species = species
    126         try:
--> 127             self.molpath = os.path.join(self.datapath,species+'.dat')
    128         except IOError:
    129             log.warn("Did not find data file for species {0} "

~/pyradex/pyradex/core.py in molpath(self, molfile)
    613         else:
    614             self.radex.impex.molfile[:] = ""
--> 615         utils.verify_collisionratefile(molfile)
    616         try:
    617             self.radex.impex.molfile[:len(molfile)] = molfile

~/pyradex/pyradex/utils.py in verify_collisionratefile(fn)
     69     from astroquery import lamda
     70
---> 71     if not os.path.exists(fn):
     72         raise IOError("File {0} does not exist.".format(fn))
     73

/anaconda3/envs/pyradex_demo/lib/python3.7/genericpath.py in exists(path)
     17     """Test whether a path exists.  Returns False for broken symbolic links"""
     18     try:
---> 19         os.stat(path)
     20     except OSError:
     21         return False

ValueError: embedded null byte

Is it expected? Does pyradex depend on pre-installed RADEX? Is it fine that tests don't run out of the box, and many of them fail if I run them manually?

I am sorry if I do something weird.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions