I have carefully checked the environment, and the two methods shows the same package directory:
>>> !pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org/
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD 3-Clause License
Location: /home/duhc/anaconda3/lib/python3.9/site-packages
Requires: packaging, numpy, PyYAML, pyerfa
Required-by: sdss-marvin, photutils, mgefit, gwcs
>>> import astropy
>>> print(astropy.__version__)
>>> print(astropy.__path__)
4.3.1
['/home/duhc/anaconda3/lib/python3.9/site-packages/astropy']
We see, the directories are the same, both are /home/duhc/anaconda3/lib/python3.9/site-packages
, while the versions are different.
This does not happen in a fresh environment:
$>conda create -n astropy python=3.9.7 astropy=5.1
$>conda activate astropy
$>pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$>python -c "import astropy; print(astropy.__version__)"
5.1
Also does not happen when the package is installed from pypi
$>conda uninstall astropy
$>pip install astropy
$>python -c "import astropy; print(astropy.__version__)"
5.1
$>pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
What probably happened is that you overwrote a pip installed package with conda. Complete steps to reproduce:
$> conda create -n astropy python=3.9.7
$> conda activate astropy
$> pip install astropy
$> pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$> conda install astropy==4.3.1
$> pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$> python -c "import astropy; print(astropy.__version__)"
4.3.1
Therefore it looks like this is not a bug of the package, but rather a good example of why you should be careful to not mix conda
and pip
commands in the same environment without care. I would especially advice against doing so in your base environment (personally, I would not change the base env at all, except for updates).