0

Context

I have a problem with healpy which gives me :

AttributeError: 'module' object has no attribute 'read_map'

After checking, I was able to see that the 'read_map' function of healpy was given by healpy.fitsfunc, and when I tried to import specifically this module :

import healpy.fitsfunc

I obtained :

Traceback (most recent call last):

  File "<ipython-input-1-1ab0f97bea12>", line 1, in <module>
    import healpy.fitsfunc

  File "/home/magdy/Documents/StageM1/cosmicvoids-vide_public-82492565081e/ext_build/python/lib/python2.7/site-packages/healpy/fitsfunc.py", line 23, in <module>
    import pyfits as pf

ImportError: No module named pyfits

Which is the reason I try to install pyfits.

Error

When I try

pip install pyfits

I obtain :

Collecting pyfits
  Using cached https://files.pythonhosted.org/packages/c0/5d/ffae283cea526bce7c1154e7309a040a3e8c02e973b2360bcfc8f30134ef/pyfits-3.5.tar.gz
    Complete output from command python setup.py egg_info:

    Installed /tmp/easy_install-HZAa1H/stsci.distutils-0.3.7/.eggs/d2to1-0.2.12.post1-py2.7.egg
    /usr/local/lib/python2.7/dist-packages/setuptools/dist.py:47: DistDeprecationWarning: Do not call this function
      warnings.warn("Do not call this function", DistDeprecationWarning)
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-QgcwJz/pyfits/setup.py", line 14, in <module>
        zip_safe=False
      File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 139, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 724, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 782, in resolve
        replace_conflicting=replace_conflicting
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1065, in best_match
        return self.obtain(req, installer)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1077, in obtain
        return installer(requirement)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 791, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 679, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 705, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 890, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1146, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error in setup command: Error parsing /tmp/easy_install-HZAa1H/stsci.distutils-0.3.7/setup.cfg: TypeError: super() argument 1 must be type, not None

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-QgcwJz/pyfits/

I have already tried :

pip install --upgrade setuptools

And a lot of other solutions, but none of them seems to work or apply to my case.

I have also tried to download directly pyfits3.5 and install it with

pip install .

but this gave me the same error.

System

Ubuntu 18.04.2 LTS (dual boot)

pip 19.0.3 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Python 2.7.15rc1

Thank you for helping me.

Mag
  • 1
  • 2
  • Hi. What actually are you trying to do (regardless of what packages you're using it for)? If you have some version of healpy that's trying to use the stand-alone pyfits package that would indicate that it's very old, as pyfits has been deprecated for some time and merged into Astropy (strange error though, might be worth looking into). How did you install healpy in the first place? – Iguananaut Mar 04 '19 at 23:52
  • Healpy looks like it has some more up to date releases so you should most likely be trying to use one of them instead: https://pypi.org/project/healpy/ (and using a conda environment or virtualenv; please try not to use pip to install things system-wide). – Iguananaut Mar 04 '19 at 23:57
  • Finally, in addition to how you installed healpy in the first place, you didn't mention what you did that resulted in the original `AttributeError`. What exactly did you do to get to that point? Something seems fishy about your entire setup. It looks to me like you're mixing together multiple python installations and/or paths. – Iguananaut Mar 05 '19 at 00:03
  • Hi, thanks for you answers. I had to install an opensource algorithm named VIDE, Void IDentification and Examination toolkit, and it installed on its own the packages it needed (those packages were given with the dowload), and what I am trying to do is to run this algorithm. It's a simple run of this algorithm on one of its example that gave me the first AttributeError. – Mag Mar 05 '19 at 15:31
  • So, the VIDE algorithm have installed a 1.4.1 Healpy version. Maybe I should mention that I previously had installed healpy with pip. When I try to upgrade it with pip, I obtain this error : Cannot uninstall 'healpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. – Mag Mar 05 '19 at 15:32
  • It looks line this VIDE toolkit comes with its own set of Python packages and possibly even it's own Python(?) and you're getting it mixed up with packages on your system's Python. Without being able to sit at your computer and figure out exactly what's going on, I would suggest finding a local system administrator or someone like that who understands Python. – Iguananaut Mar 06 '19 at 13:00
  • You definitely shouldn't be trying to `pip install` *anything* on your system unless you're using a virtualenv, a conda env, or a user site-packages in `~/.local`. If you don't know what any of those things are you also definitely shouldn't be `pip install`ing anything because you could accidentally override some packages on your system Python leading to incompatibilities that are hard to understand. – Iguananaut Mar 06 '19 at 13:03
  • Thanks ! I finally managed to get rid of the first problem by deleting the healpy content of the VIDE toolkit and installing it properly with conda ! I don't know if I should also get rid of everything I previously installed with pip, and re-install it with conda. I have now another error with the VIDE toolkit on a basic example, and the solution to this issue seem to make the toolkit fail its operation, so I will try to solve this now. – Mag Mar 06 '19 at 16:05
  • "I finally managed to get rid of the first problem by deleting the healpy content of the VIDE toolkit and installing it properly with conda" Sorry, I should have been more clear: You definitely should not have done that either! If the VIDE toolkit is including its own Python packages then when you try to use it you should only be using the Python package's *it* is providing in its own environment, which (presumably) are the correct versions it uses. You should not be trying to mix together different Python environments. Your original problem I think arose from mixing environments – Iguananaut Mar 06 '19 at 17:02
  • I'm downloading the source code from https://bitbucket.org/cosmicvoids/vide_public/ to see what's going on. How did you install it in the first place? – Iguananaut Mar 06 '19 at 17:12
  • From reading the scant documentation at https://bitbucket.org/cosmicvoids/vide_public/wiki/Home, it seems that it puts a bunch of Python packages in its own site-packages, but then expects you to put that path on your PYTHONPATH environment variable manually, which is...not very good. If you didn't do that to start with then you'd be using the wrong versions if various packages. So make sure you do like `export PYTHONPATH=/home/magdy/Documents/StageM1/cosmicvoids-vide_public-82492565081e/ext_build/python/lib/python2.7/site-packages/` before running their scripts. – Iguananaut Mar 06 '19 at 17:18
  • But reintall it first because if you `rm -rf`'d the installation of healpy that was there then it's essentially broken :/ – Iguananaut Mar 06 '19 at 17:19
  • In case this was going to be wrong, I cut/paste the healpy content out of VIDE (and saved its location), so I can replace it on its original location. As for the installation of VIDE, I did follow the instructions of the documentation ( https://bitbucket.org/cosmicvoids/vide_public/wiki/Installation ) but I lacked a lot of packages to properly do it, so I installed them via pip. Given it was a bad idea, I may should reinstall VIDE anyway using an environnment and install the missing package within that same env. – Mag Mar 06 '19 at 18:03
  • I also did put the PYTHONPATH variable before running their scripts. I was also able to install PyFits via pip install pyfits on a conda environnment ! – Mag Mar 06 '19 at 18:07

0 Answers0