Installing error

Issue #89 resolved
Yuanjia Wang created an issue

Hi, I have installed petsc 3.6.2 and other dependencies of petsc4py. But when I tried to install petsc4py, I always failed with the error

module 'petsc' has no attribute 'get_petsc_dir'

I installed petsc by

 sudo apt-get install petsc-dev

and installed petsc4py by

sudo pip3 install petsc4py

the log shows

The directory '/home/wyj/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/wyj/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting petsc4py
  Downloading petsc4py-3.8.1.tar.gz (1.6MB)
    100% |████████████████████████████████| 1.6MB 398kB/s 
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/petsc4py.egg-info
    writing pip-egg-info/petsc4py.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/petsc4py.egg-info/dependency_links.txt
    writing requirements to pip-egg-info/petsc4py.egg-info/requires.txt
    writing top-level names to pip-egg-info/petsc4py.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/petsc4py.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-znbp4263/petsc4py/setup.py", line 267, in <module>
        main()
      File "/tmp/pip-build-znbp4263/petsc4py/setup.py", line 264, in main
        run_setup()
      File "/tmp/pip-build-znbp4263/petsc4py/setup.py", line 137, in run_setup
        **setup_args)
      File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 186, in run
        self.find_sources()
      File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 209, in find_sources
        mm.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 293, in run
        self.add_defaults()
      File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 322, in add_defaults
        sdist.add_defaults(self)
      File "/usr/lib/python3/dist-packages/setuptools/command/sdist.py", line 120, in add_defaults
        build_py = self.get_finalized_command('build_py')
      File "/usr/lib/python3.6/distutils/cmd.py", line 299, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3.6/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/command/build_py.py", line 33, in finalize_options
        orig.build_py.finalize_options(self)
      File "/usr/lib/python3.6/distutils/command/build_py.py", line 45, in finalize_options
        ('force', 'force'))
      File "/usr/lib/python3.6/distutils/cmd.py", line 287, in set_undefined_options
        src_cmd_obj.ensure_finalized()
      File "/usr/lib/python3.6/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/tmp/pip-build-znbp4263/petsc4py/conf/baseconf.py", line 404, in finalize_options
        self.petsc_dir  = config.get_petsc_dir(self.petsc_dir)
      File "/tmp/pip-build-znbp4263/petsc4py/conf/baseconf.py", line 342, in get_petsc_dir
        petsc_dir = petsc.get_petsc_dir()
    AttributeError: module 'petsc' has no attribute 'get_petsc_dir'

Had anyone met the same problem?

Thanks for any advice.

Comments (5)

  1. Yuanjia Wang reporter

    Hello, I have forgotten how I successfully installed it.. but I remember that the reason that module 'petsc' has no attribute 'get_petsc_dir' is you didn't successfully installed petsc. You can find if you have multiple versions of python on you OS, then try pipX( X is the version of python you are using) for both petsc and petsc4py

  2. Lisandro Dalcin
    1. You need to install a petsc4py X.Y version that match the PETSc X.Y version (just the major.minor versions should match, the last minor or patch version can be different).

    2) You have to export PETSC_DIR=/path/to/petsc for pip install petsc4py=<version> to work.

  3. Georgie Long

    It took a bit of further digging to fix why petsc wasn't installing (I had to reinstall gfortran and a couple of libraries), but once I'd managed to install that, petsc4py installed successfully. Thanks for your help!

  4. Log in to comment