Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

The astropy<5,>=3.2 dependency makes poliastro not installable on Python 3.10.2 since astropy-4.3.1 does not install on that version of python #1496

Closed
danielk333 opened this issue Apr 6, 2022 · 11 comments

Comments

@danielk333
Copy link

🐞 Problem

When installing poliastro trough pip on python 3.10.2 it uses astropy-4.3.1 which fails installation with the error message ImportError: cannot import name 'soft_unicode' from 'markupsafe'.

🖥 Please paste the output of following commands

# Paste your output here:
(poliastro) danielk@IRF033-danielk ~/python_scripts> pip freeze
appdirs==1.4.4
application-utility==1.3.2
arandr==0.1.10
btrfsutil==5.16.2
CacheControl==0.12.6
ceph==1.0.0
ceph-volume==1.0.0
cephfs==2.0.0
cephfs-shell==0.0.1
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
colorama==0.4.4
contextlib2==0.6.0.post1
crit==0.0.1
cryptography==36.0.1
Cython==0.29.28
distlib==0.3.4
distro==1.7.0
dnspython==2.2.0
docopt==0.6.2
gufw==21.4.0
html5lib==1.1
idna==3.3
importlib-metadata==4.8.1
keyutils==0.6
lensfun==0.3.3
lightdm-gtk-greeter-settings==1.2.2
lit==13.0.1.dev0
louis==3.21.0
manjaro-sdk==0.1
Markdown==3.3.6
menulibre==2.2.3
more-itertools==8.10.0
msgpack==1.0.3
mugshot==0.4.3
nftables==0.1
npyscreen==4.10.5
numpy==1.22.3
ordered-set==4.0.2
packaging==20.9
pacman-mirrors==4.23.2
pep517==0.12.0
pexpect==4.8.0
ply==3.11
progress==1.6
protobuf==3.19.4
psutil==5.9.0
ptyprocess==0.7.0
pycairo==1.20.1
pycparser==2.21
PyGObject==3.42.0
pyOpenSSL==21.0.0
pyparsing==3.0.1
PyQt5==5.15.6
PyQt5-sip==12.9.1
PySide6==6.2.3
python-distutils-extra==2.39
pyxdg==0.27
PyYAML==6.0
rados==2.0.0
ranger-fm==1.9.3
rbd==2.0.0
requests==2.27.1
resolvelib==0.5.5
retrying==1.3.3
rgw==2.0.0
screenkey==1.5
shiboken6==6.2.3
six==1.16.0
systemd-python==234
TBB==0.2
team==1.0
toml==0.10.2
tomli==2.0.0
udiskie==2.4.2
ufw==0.36.1
urllib3==1.26.8
vimiv==0.8.0
webencodings==0.5.1
zipp==3.7.0

💡 Possible solutions

Upgrading the dependency to astropy>=5 and consequence revising the usage of astropy accordingly would probably make poliastro also support python >= 3.10.

@astrojuanlu
Copy link
Member

Hello @danielk333 , thanks for opening this issue!

The error you mention seems to be pallets/markupsafe#284. However, I don't see markupsafe in your pip freeze, as I don't see astropy or poliastro either. I suspect your pip freeze is not displaying the dependencies you wanted to share.

Can you paste a complete traceback of the error you are witnessing?

@danielk333
Copy link
Author

danielk333 commented Apr 7, 2022

Thanks for the quick reply, below is the entire terminal-dump of the commands and output.


(poliastro) danielk@IRF033-danielk ~/python_scripts> pip install poliastro
Collecting poliastro
  Using cached poliastro-0.16.2-py3-none-any.whl (142 kB)
Collecting matplotlib!=3.0.1,>=2.0
  Using cached matplotlib-3.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.9 MB)
Collecting scipy>=1.4.0
  Using cached scipy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.3 MB)
Collecting pandas
  Downloading pandas-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.7/11.7 MB 78.3 MB/s eta 0:00:00
Collecting pyerfa
  Using cached pyerfa-2.0.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (743 kB)
Collecting numba>=0.53.0
  Using cached numba-0.55.1-1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.3 MB)
Collecting jplephem
  Using cached jplephem-2.17.tar.gz (40 kB)
  Preparing metadata (setup.py) ... done
Collecting plotly<6,>=4.0
  Using cached plotly-5.7.0-py2.py3-none-any.whl (28.8 MB)
Requirement already satisfied: numpy in /usr/lib/python3.10/site-packages (from poliastro) (1.22.3)
Collecting astropy<5,>=3.2
  Using cached astropy-4.3.1.tar.gz (7.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      Traceback (most recent call last):
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 70, in <module>
          ext_modules=get_extensions())
        File "/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/extension_helpers/_setup_helpers.py", line 67, in get_extensions
          ext_modules.extend(setuppkg.get_extensions())
        File "./astropy/modeling/setup_package.py", line 59, in get_extensions
          from jinja2 import Environment, FileSystemLoader
        File "/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/jinja2/__init__.py", line 33, in <module>
          from jinja2.environment import Environment, Template
        File "/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/jinja2/environment.py", line 15, in <module>
          from jinja2 import nodes
        File "/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/jinja2/nodes.py", line 19, in <module>
          from jinja2.utils import Markup
        File "/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/jinja2/utils.py", line 642, in <module>
          from markupsafe import Markup, escape, soft_unicode
      ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/danielk/tmp/pip-build-env-d2cm3zwu/overlay/lib/python3.10/site-packages/markupsafe/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel 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.
(poliastro) danielk@IRF033-danielk ~/python_scripts> pip freeze
appdirs==1.4.4
application-utility==1.3.2
arandr==0.1.10
btrfsutil==5.16.2
CacheControl==0.12.6
ceph==1.0.0
ceph-volume==1.0.0
cephfs==2.0.0
cephfs-shell==0.0.1
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
colorama==0.4.4
contextlib2==0.6.0.post1
crit==0.0.1
cryptography==36.0.1
Cython==0.29.28
distlib==0.3.4
distro==1.7.0
dnspython==2.2.0
docopt==0.6.2
gufw==21.4.0
html5lib==1.1
idna==3.3
importlib-metadata==4.8.1
keyutils==0.6
lensfun==0.3.3
lightdm-gtk-greeter-settings==1.2.2
lit==13.0.1.dev0
louis==3.21.0
manjaro-sdk==0.1
Markdown==3.3.6
menulibre==2.2.3
more-itertools==8.10.0
msgpack==1.0.3
mugshot==0.4.3
nftables==0.1
npyscreen==4.10.5
numpy==1.22.3
ordered-set==4.0.2
packaging==20.9
pacman-mirrors==4.23.2
pep517==0.12.0
pexpect==4.8.0
ply==3.11
progress==1.6
protobuf==3.19.4
psutil==5.9.0
ptyprocess==0.7.0
pycairo==1.20.1
pycparser==2.21
PyGObject==3.42.0
pyOpenSSL==21.0.0
pyparsing==3.0.1
PyQt5==5.15.6
PyQt5-sip==12.9.1
PySide6==6.2.3
python-distutils-extra==2.39
pyxdg==0.27
PyYAML==6.0
rados==2.0.0
ranger-fm==1.9.3
rbd==2.0.0
requests==2.27.1
resolvelib==0.5.5
retrying==1.3.3
rgw==2.0.0
screenkey==1.5
shiboken6==6.2.3
six==1.16.0
systemd-python==234
TBB==0.2
team==1.0
toml==0.10.2
tomli==2.0.0
udiskie==2.4.2
ufw==0.36.1
urllib3==1.26.8
vimiv==0.8.0
webencodings==0.5.1
youtube-dl==2021.12.17
zipp==3.7.0
(poliastro) danielk@IRF033-danielk ~/python_scripts> pip --version
pip 22.0.4 from /home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip (python 3.10)
(poliastro) danielk@IRF033-danielk ~/python_scripts> 

@danielk333
Copy link
Author

I can also add that astropy install results in this for 4.3.1

(poliastro) danielk@IRF033-danielk ~/python_scripts> pip install astropy==4.3.1
Collecting astropy==4.3.1
  Using cached astropy-4.3.1.tar.gz (7.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      Traceback (most recent call last):
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/danielk/venvs/poliastro/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 70, in <module>
          ext_modules=get_extensions())
        File "/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/extension_helpers/_setup_helpers.py", line 67, in get_extensions
          ext_modules.extend(setuppkg.get_extensions())
        File "./astropy/modeling/setup_package.py", line 59, in get_extensions
          from jinja2 import Environment, FileSystemLoader
        File "/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/jinja2/__init__.py", line 33, in <module>
          from jinja2.environment import Environment, Template
        File "/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/jinja2/environment.py", line 15, in <module>
          from jinja2 import nodes
        File "/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/jinja2/nodes.py", line 19, in <module>
          from jinja2.utils import Markup
        File "/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/jinja2/utils.py", line 642, in <module>
          from markupsafe import Markup, escape, soft_unicode
      ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/danielk/tmp/pip-build-env-4ogjqgle/overlay/lib/python3.10/site-packages/markupsafe/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel 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.

and this for 5.0.4

(poliastro) danielk@IRF033-danielk ~/python_scripts> pip install astropy
Collecting astropy
  Using cached astropy-5.0.4-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (11.1 MB)
Requirement already satisfied: packaging>=19.0 in /usr/lib/python3.10/site-packages (from astropy) (20.9)
Requirement already satisfied: PyYAML>=3.13 in /usr/lib/python3.10/site-packages (from astropy) (6.0)
Requirement already satisfied: numpy>=1.18 in /usr/lib/python3.10/site-packages (from astropy) (1.22.3)
Collecting pyerfa>=2.0
  Using cached pyerfa-2.0.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (743 kB)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/lib/python3.10/site-packages (from packaging>=19.0->astropy) (3.0.1)
Installing collected packages: pyerfa, astropy
Successfully installed astropy-5.0.4 pyerfa-2.0.0.1

@astrojuanlu
Copy link
Member

I see - so, the problem is that "pip install 'astropy<5'" fails on Python 3.10? Probably this should be reported upstream.

At some point soon we'll release a bugfix for compatibility with Astropy 5.

@danielk333
Copy link
Author

danielk333 commented Apr 8, 2022

I hesitated to open an issue upstream on it as astropy states

Please check that the development version still produces the same bug.
You can install development version with
pip install git+https://github.com/astropy/astropy
command

which it does not since they fixed that problem in astropy>=5.

@astrojuanlu
Copy link
Member

Good point. In that case, I'll keep this open so that we can make poliastro work with the latest version of Astropy

@yakkonaut
Copy link

Just leaving notes for folks who find themselves here after a google search:
The issue with installing the older version of astropy actually goes back to the library markupsafe which deprecated "soft_unicode" in favor of "soft_str"... then broke it in a minor version.

Ref: pallets/markupsafe#284

As @danielk333 noted, astropy 5.x fixed this.

I'm trying to integrate someone else's code in to an existing project where they used poliastro... I wouldn't put this issue specifically on the poliastro or astropy teams- it's weird that markupsafe did this breaking change on a minor version. That said, now I can't figure out if it will be faster to change the math to skyfield or to try and help fix poliastro. I'm brand new to this codebase- will start reading around. Appreciate you all!

@yakkonaut
Copy link

Sorry for double post- derpped. I saw the markupsafe ref above but didn't realize it linked to the same issue. Point still stands though, it's an awkward fix they could have avoided by not forcing deprecation until next major version -,-

@astrojuanlu
Copy link
Member

Thanks for the extra info @yakkonaut - all help is welcome to make poliastro work with Astropy 5 (#1493). I'm on PTO and ramping up a new job but I hope I'll have the resources to cut a bugfix release soon.

I'm trying to integrate someone else's code in to an existing project where they used poliastro...

Would love to know more, feel free to reach out in private :)

@astrojuanlu
Copy link
Member

Hopefully #1501 fixes this, please have a look.

@astrojuanlu
Copy link
Member

Closed in poliastro 0.16.3 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants