Menu

adding proper to conda environment

KDavis
2019-01-23
2019-02-13
  • KDavis

    KDavis - 2019-01-23

    Has anyone tried to add proper to a conda environment? The setup.py didn't work as a pip-install on my machine. I did run the setup.py while in an environment, but it wasn't added automatically.

     
    • KDavis

      KDavis - 2019-02-13

      Thank you for the above suggestion. I was able to get Proper installed into
      a conda environment.

      On a different note, I have a code suggestion for you regarding Proper.

      This is something I have run into trying to get proper to run prescriptions
      that I have defined elsewhere. For various reasons, I am running the code
      from a remote directory relative to where the prescriptions are stored.
      When I try to then run proper, I need to specify the relative location of
      the perscription to the prop_run.py code. However, it states in the intro
      of the code:

      def prop_run(routine_name, lambda0, gridsize, **kwargs):
      """Execute a prescription.

      Parameters
      ----------
      routine_name : str
          Filename (excluding extension) of the python routine containing the
          prescription.
      

      So the filename cannot include the extension. I believe it says that
      because in lines 129-135 you use a function to import the module, and then
      get the specific prescription from the module using python's internal
      getattr:

      try:
      module = importlib.import_module(routine_name)
      except ImportError:
      raise ImportError("Unable to run %s prescription. Stopping." %routine_name)

      func = getattr(module, routine_name)

      routine_name is one of the arguments passed into prop_run as a string.
      importlib.import_module() then imports the module and stores it as a
      variable, module. the importlib statement can easily handle relative path
      names. However, the next line where func = getattr(module, routine_name)
      will break if routine_name is a relative path string.

      You can fix this with the following lines of code:

      f1 = os.path.basename(module.file)
      f2 = os.path.splitext(f1)[0]
      func = getattr(module, f2)

      This will give you the attrube with the name stored in f2 of the module and
      save it as func. This will work regardless of what is specified in
      routine_name since the .file global attribute gives the full path name
      of whatever was returned by the importlib statement.

      I hope this is helpful and relevant information. You could probably cram
      that all into a single line if you wanted, but at the expense of
      readability. Please consider updating the prop_run.py file.

      Thank you,
      Kristina

      On Wed, Jan 23, 2019 at 11:07 AM KDavis kyle-astro@users.sourceforge.net
      wrote:

      Has anyone tried to add proper to a conda environment? The setup.py didn't
      work as a pip-install on my machine. I did run the setup.py while in an
      environment, but it wasn't added automatically.


      adding proper to conda environment
      https://sourceforge.net/p/proper-library/discussion/general/thread/b5f4f491aa/?limit=25#1e2d


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/proper-library/discussion/general/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Kristina K. Davis, PhD.
      Astronomy & Astrophysics Postdoctoral Fellow
      National Science Foundation
      University of California, Santa Barbara
      k_davis@physics.ucsb.edu
      kristinadavis.weebly.com

       
  • John Krist

    John Krist - 2019-02-05

    Sorry for the delay - I had to get my Python person to figure this out. Here's what he said. Let me know if this works.


    Yes, I was able to create a conda environment for python 2.7 PROPER and run examples. Few points to note:

    1. Conda does not work seamlessly with pip installer. One has to install supporting packages using conda (if they are available) rather than pip and only install packages using pip that are not available in conda.
    2. Pyfits is deprecated and FITS write/read module in astropy should be used
    3. Latest version of astropy (version 3.0) does not support Python 2.7. One has to explicitly use astropy version 2.0 in Python 2.7

    Steps to setup conda environment for Python 2.7:
    1. (optional) Update conda
    > conda update -n base conda

    1. Create a new conda environment for PROPER
      > conda create --name PROPER2.7

    The conda environment could be named anything the user desires.

    1. Install required and optional packages in the conda environment (these version worked for me)

      conda install -n PROPER2.7 python=2.7 numpy=1.15 scipy=1.2 astropy=2.0 ipython matplotlib

    ipython and matplotlib are optional.

    1. Remove any install PROPER packages from user's local directory ($HOME/.local)

    2. Activate PROPER conda environment

      source conda activate PROPER2.7

    3. Install PyPROPER package inside conda environment

      python setup.py install

    4. Once successfully installed, try the following in python or ipython sheel to see if proper is installed correctly

    import proper
    proper.version

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.