Good evening, everibody, Does fenics work with python or only with C++? Can I use visual studio code as an editor without creating a conflict?
You can use FEniCS in either language. However, most users prefer the Python interface.
Yes, you can. I’ve been using vscode for developing with FEniCS since 2020
Thanks for your answers dokken, I have tried to install fenics on my PC with a Windows 10 environment to work with Visual Studio code in Python 3.13.1 but I get an error when running the program. ModuleNotFoundError: No module named ‘fenics’, I have tried several times and nothing, I don’t know if you could help me with this?
The module is called dolfinx
, not fenics
. Various beginner guides exist, which you’re encouraged to go through to get started. E.g., The FEniCSx tutorial — FEniCSx tutorial and the demos on Demos — DOLFINx 0.9.0 documentation
Thanks Stein, I have tried to install Petsc4py the following error appears
*** Windows python detected. Please rerun ./configure with cygwin-python. ***
===============================================================================
Traceback (most recent call last):
File “C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py”, line 389, in
main()
~~~~^^
File “C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py”, line 373, in main
json_out[“return_val”] = hook(**hook_input[“kwargs”])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py”, line 280, in build_wheel
return _build_backend().build_wheel(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
wheel_directory, config_settings, metadata_directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\build_meta.py”, line 438, in build_wheel
return _build([‘bdist_wheel’, ‘–dist-info-dir’, str(metadata_directory)])
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\build_meta.py”, line 426, in _build
return self._build_with_temp_dir(
~~~~~~~~~~~~~~~~~~~~~~~~~^
cmd,
^^^^
…<3 lines>…
self._arbitrary_args(config_settings),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\build_meta.py”, line 407, in build_with_temp_dir
self.run_setup()
~~~~~~~~~~~~~~^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\build_meta.py”, line 320, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File “”, line 366, in
File "C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_init.py", line 117, in setup
return distutils.core.setup(**attrs)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\core.py”, line 186, in setup
return run_commands(dist)
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\core.py”, line 202, in run_commands
dist.run_commands()
~~~~~~~~~~~~~~~~~^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\dist.py”, line 983, in run_commands
self.run_command(cmd)
~~~~~~~~~~~~~~~~^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\dist.py”, line 999, in run_command
super().run_command(command)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\dist.py”, line 1002, in run_command
cmd_obj.run()
~~~~~~~~~~~^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\command\bdist_wheel.py”, line 414, in run
self.run_command(“install”)
~~~~~~~~~~~~~~~~^^^^^^^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\cmd.py”, line 339, in run_command
self.distribution.run_command(command)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools\dist.py”, line 999, in run_command
super().run_command(command)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File “C:\Users\User\AppData\Local\Temp\pip-build-env-7_osh60f\overlay\Lib\site-packages\setuptools_distutils\dist.py”, line 1002, in run_command
cmd_obj.run()
~~~~~~~~~~~^^
File “”, line 289, in run
File “”, line 192, in config
RuntimeError: 3
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for petsc
Failed to build petsc
ERROR: Failed to build installable wheels for some pyproject.toml based projects (petsc)
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
How did you install dolfinx/dolfin/fenics on your system?
You can also use devcontainerin vscode with the Fenicsx docker image
something like this
Dokerfile
FROM dolfinx/dolfinx:stable
.....
devcontainer.json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "project",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "./Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"donjayamanne.python-extension-pack",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"njpwerner.autodocstring",
"ms-toolsai.datawrangler",
"498.pythonformat"
]
}
}
}