tletools icon indicating copy to clipboard operation
tletools copied to clipboard

Clunky fix for installing on Debian Bookworm - Python 3.11

Open kazzle101 opened this issue 2 years ago • 1 comments

Hello Installing on my Debian bookworm setup using sudo pip install TLE-tools gave this error:

        196 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Can't roll back astropy; was not uninstalled
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> astropy

to fix this I do the following:

sudo apt install astropy
cd ~
git clone https://github.com/FedericoStra/tletools.git
cd tletools

then edited setup.py and changed 'astropy>=3.2.0' to 'astropy>=5.2.1'' in the install_requires` section, saved the file then continued with:

sudo python setup.py install

It looks like the setup is choosing the old 3.2.1 version rather than that supplied by the debian install

Hope that helps someone

Karl

kazzle101 avatar Nov 21 '23 12:11 kazzle101

Thanks for figuring out that work around. After getting it installed I'm seeing the following error with Python 3.12.3.

$ python3 -m venv ~/.tle
$ source ~/.tle/bin/activate

$ git clone https://github.com/FedericoStra/tletools
$ cd tletools/
$ vi setup.py
diff --git a/setup.py b/setup.py
index 2dfd79e..027a762 100755
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ setup(
         'attrs>=19.0.0',
         'numpy>=1.16.0',
         'pandas>=0.24.0',
-        'astropy>=3.2.0',
+        'astropy>=5.2.1',
         'poliastro>=0.14.0',
     ],
     tests_require=[
$ pip install setuptools
$ python setup.py install
In [1]: import json
   ...:
   ...: from tletools import TLE
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 3
      1 import json
----> 3 from tletools import TLE

File ~/.tle/lib/python3.12/site-packages/tletools/__init__.py:7
      1 """
      2 **TLE-tools** is a small library to work with `two-line element set`_ files.
      3
      4 .. _`two-line element set`: https://en.wikipedia.org/wiki/Two-line_element_set
      5 """
----> 7 from .tle import TLE
      8 from .pandas import load_dataframe, add_epoch

File ~/.tle/lib/python3.12/site-packages/tletools/tle.py:25
      1 '''
      2 The module :mod:`tletools.tle` defines the classes :class:`TLE` and :class:`TLEu`.
      3
   (...)     22 .. autoclass:: TLEu
     23 '''
---> 25 import attr
     27 import numpy as np
     28 import astropy.units as u

ModuleNotFoundError: No module named 'attr'

It looks like the above setup didn't install the dependencies. When I tried to install them I hit a roadblock with poliastro:

$ pip install .
Processing /mnt/d/code_gis/tletools
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: attrs>=19.0.0 in /home/mark/.tle/lib/python3.12/site-packages (from TLE-tools==0.2.4) (25.3.0)
Requirement already satisfied: numpy>=1.16.0 in /home/mark/.tle/lib/python3.12/site-packages (from TLE-tools==0.2.4) (2.3.1)
Collecting pandas>=0.24.0 (from TLE-tools==0.2.4)
  Using cached pandas-2.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (91 kB)
Collecting astropy>=5.2.1 (from TLE-tools==0.2.4)
  Using cached astropy-7.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (10 kB)
INFO: pip is looking at multiple versions of tle-tools to determine which version is compatible with other requirements. This could take a while.
ERROR: Ignored the following versions that require a different python version: 0.13.0 Requires-Python >=3.6,<3.8; 0.13.1 Requires-Python <3.8,>=3.6; 0.13b1 Requires-Python >=3.6,<3.8; 0.14.0 Requires-Python >=3.6,<3.9; 0.14b1 Requires-Python >=3.6,<3.9; 0.15.0 Requires-Python >=3.7,<3.10; 0.15.2 Requires-Python >=3.7,<3.10; 0.15b1 Requires-Python >=3.7,<3.10; 0.16.0 Requires-Python >=3.7,<3.10; 0.16.1 Requires-Python >=3.8,<3.11; 0.16.2 Requires-Python >=3.8,<3.11; 0.16.3 Requires-Python >=3.8,<3.11; 0.16b1 Requires-Python >=3.7,<3.10; 0.17.0 Requires-Python >=3.8,<3.11
ERROR: Could not find a version that satisfies the requirement poliastro>=0.14.0 (from tle-tools) (from versions: 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.3.0, 0.3.2, 0.3.3, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.7.dev0, 0.7.0b1, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.11b1, 0.11.0, 0.11.1, 0.12b1, 0.12.0)
ERROR: No matching distribution found for poliastro>=0.14.0

I'm working on using a fork of poliastro:

diff --git a/setup.py b/setup.py
index 2dfd79e..a20fffa 100755
--- a/setup.py
+++ b/setup.py
@@ -24,8 +24,8 @@ setup(
         'attrs>=19.0.0',
         'numpy>=1.16.0',
         'pandas>=0.24.0',
-        'astropy>=3.2.0',
-        'poliastro>=0.14.0',
+        'astropy>=5.2.1',
+        'hapsira',
     ],
     tests_require=[
         'flake8>=3.7.0',
diff --git a/tletools/tle.py b/tletools/tle.py
index 7ad7ff6..fa0120c 100644
--- a/tletools/tle.py
+++ b/tletools/tle.py
@@ -29,8 +29,8 @@ import astropy.units as u
 from astropy.time import Time

 # Maybe remove them from here?
-from poliastro.twobody import Orbit as _Orbit
-from poliastro.bodies import Earth as _Earth
+from hapsira.twobody import Orbit as _Orbit
+from hapsira.bodies import Earth as _Earth

 from .utils import partition, rev as u_rev, M_to_nu as _M_to_nu

diff --git a/tletools/utils.py b/tletools/utils.py
index e99af07..3b23941 100644
--- a/tletools/utils.py
+++ b/tletools/utils.py
@@ -1,6 +1,6 @@
 import numpy as np
 import astropy.units as u
-from poliastro.core.angles import M_to_E as _M_to_E, E_to_nu as _E_to_nu
+from hapsira.core.angles import M_to_E as _M_to_E, E_to_nu as _E_to_nu

 #: :class:`numpy.dtype` for a date expressed as a year.
 dt_dt64_Y = np.dtype('datetime64[Y]')

This is the latest roadblock I've hit. There seems to be an un-merged pull request for this https://github.com/pleiszenburg/hapsira/pull/20/files

I'll update this ticket as I find workarounds:

ImportError: cannot import name 'matrix_product' from 'astropy.coordinates.matrix_utilities' (/home/mark/.tle/lib/python3.12/site-packages/astropy/coordinates/matrix_utilities.py)

marklit avatar Jul 23 '25 05:07 marklit