And got with SunPy 5.1 and SunPy 6.0.0 and Python 3.12 (Miniconda3 + a pip install of sunpy)
File “/opt/miniconda3/lib/python3.12/site-packages/sunpy/net/helio/hec.py”, line 7, in
from lxml import etree
ModuleNotFoundError: No module named ‘lxml’
File “/opt/miniconda3/lib/python3.12/site-packages/sunpy/net/helio/hec.py”, line 7, in
from lxml import etree
ModuleNotFoundError: No module named ‘lxml’
With Python 3.10.14 and SunPy 6.0.0, I get
File “/opt/miniconda3/envs/python3.10.14/lib/python3.10/site-packages/sunpy/net/scraper.py”, line 14, in
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named ‘bs4’
I later followed the instructions for using conda instead of pip to install SunPy and it worked. Is the issue I had using the pip install a bug, and if so, where should I report it? I’ve been using SunPy coordinate transforms functions with SunPy installed using pip in a conda virtual environment without issue.
I know conda+pip can be a problem, and there seems not to be a way for the user to be told when it won’t work. However, I usually use pip as a first try because I’ve never had a problem with a conda base install + pip install before, using conda install usually requires extra conda config commands to look up, and I’ve never encountered a case where a package was available as a conda package but not pip (but many vice-versa cases).
This is a consequence of just doing pip install sunpy, as that does not install any of the optional dependencies which are broken out per subpackage within sunpy.
In a recent release, I think 6.0 (not sure), now a message is raised if optional packages are missing, so just a pip install sunpy enviroment, when I go to run that script, the following is now output.
WARNING: SunpyUserWarning: Importing sunpy.net without its extra dependencies may result in errors.
The following packages are not installed:
['beautifulsoup4>=4.11.0', 'drms>=0.7.1', 'python-dateutil>=2.8.1', 'zeep>=4.1.0']
To install sunpy with these dependencies use `pip install sunpy[net]` or `pip install sunpy[all]` for all extras.
If you installed sunpy via conda, please report this to the community channel: https://matrix.to/#/#sunpy:openastronomy.org [sunpy.util.sysinfo]
Traceback (most recent call last):
File "/Users/nabil/Git/sunpy/examples/acquiring_data/querying_the_GOES_event_list.py", line 8, in <module>
from sunpy.net import Fido
File "/Users/nabil/micromamba/envs/sunpy-test/lib/python3.13/site-packages/sunpy/net/__init__.py", line 9, in <module>
from sunpy.net import dataretriever as _
File "/Users/nabil/micromamba/envs/sunpy-test/lib/python3.13/site-packages/sunpy/net/dataretriever/__init__.py", line 11, in <module>
from .client import *
File "/Users/nabil/micromamba/envs/sunpy-test/lib/python3.13/site-packages/sunpy/net/dataretriever/client.py", line 11, in <module>
from sunpy.net.scraper import Scraper
File "/Users/nabil/micromamba/envs/sunpy-test/lib/python3.13/site-packages/sunpy/net/scraper.py", line 13, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
An oversight here is that lxml is not a listed dependency even though it should be.
lxml is a dependency of zeep, if one were to install pip sunpy[net], then that example will work.
Within the net subpackage, we import everything at the top level init file, so all the dependencies need to be installed otherwise, any import of Fido will error.