Hello,
I need to use open framework openMDAO for my project in Ubuntu. Which needs mpi4py and petsc4py, I have installed mpi4py using pip command $ pip install mpi4py.
But I am not able to install petsc4py using command $ pip install petsc petsc4py. It gives error as follows:
(base) mujahed@Lenovo-G50-80:~$ pip install petsc petsc4py
Collecting petsc
Using cached petsc-3.13.4.tar.gz (14.9 MB)
Collecting petsc4py
Using cached petsc4py-3.13.0.tar.gz (1.9 MB)
ERROR: Command errored out with exit status 1:
command: /home/mujahed/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bwcqa2gd/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bwcqa2gd/petsc4py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-kjttgt6a
cwd: /tmp/pip-install-bwcqa2gd/petsc4py/
Complete output (52 lines):
running egg_info
creating /tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info
writing /tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info/dependency_links.txt
writing requirements to /tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info/requires.txt
writing top-level names to /tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-kjttgt6a/petsc4py.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-bwcqa2gd/petsc4py/setup.py", line 270, in <module>
main()
File "/tmp/pip-install-bwcqa2gd/petsc4py/setup.py", line 267, in main
run_setup()
File "/tmp/pip-install-bwcqa2gd/petsc4py/setup.py", line 119, in run_setup
setup(packages = ['petsc4py',
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/home/mujahed/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/mujahed/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/mujahed/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 297, in run
self.find_sources()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 304, in find_sources
mm.run()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 535, in run
self.add_defaults()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 571, in add_defaults
sdist.add_defaults(self)
File "/home/mujahed/anaconda3/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
self._add_defaults_python()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
build_py = self.get_finalized_command('build_py')
File "/home/mujahed/anaconda3/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/home/mujahed/anaconda3/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/home/mujahed/anaconda3/lib/python3.8/site-packages/setuptools/command/build_py.py", line 39, in finalize_options
orig.build_py.finalize_options(self)
File "/home/mujahed/anaconda3/lib/python3.8/distutils/command/build_py.py", line 43, in finalize_options
self.set_undefined_options('build',
File "/home/mujahed/anaconda3/lib/python3.8/distutils/cmd.py", line 287, in set_undefined_options
src_cmd_obj.ensure_finalized()
File "/home/mujahed/anaconda3/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/tmp/pip-install-bwcqa2gd/petsc4py/conf/baseconf.py", line 398, in finalize_options
self.petsc_dir = config.get_petsc_dir(self.petsc_dir)
File "/tmp/pip-install-bwcqa2gd/petsc4py/conf/baseconf.py", line 336, in get_petsc_dir
petsc_dir = petsc.get_petsc_dir()
AttributeError: module 'petsc' has no attribute 'get_petsc_dir'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I don’t have computer science background and this is the first time I am dealing with something like mpi.
I have Ubuntu 20.04.1 LTS and I am using Anaconda3 as well.
Can anyone please help ?
Get PETSc (which is not a Python package) installed by pip is not so easy. I recommend running
pip uninstall petsc; pip install petsc; pip install petsc4py;. However, you should really install PETSc yourself wherever you want, set thePETSC_DIRenvironment variable, thenpip install petsc4pyOr maybe you should look at using Anaconda Python and packages from the conda-forge channel, they provide petsc and petsc4py ready to be used.