Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation seems fine but import-issues #28

Open
brunkowacodes opened this issue Dec 12, 2023 · 1 comment
Open

Installation seems fine but import-issues #28

brunkowacodes opened this issue Dec 12, 2023 · 1 comment

Comments

@brunkowacodes
Copy link

brunkowacodes commented Dec 12, 2023

Hey,
I don't know if someone still reads this, but I'm trying to run this package in python 3.10.

I installed it, via

  1. Git clone

  2. Inserting a cast to an int in the last function in frechet (line 534..), because it didnt compile:

          while(len(cc)!=1):
          m_i=int(len(cc)/2-1)
          eps = cc[m_i]
          rep = _decision_problem(P,Q,p,q,eps)
          if rep:
              cc=cc[:m_i+1]
          else:
              cc=cc[m_i+1:]
         return eps
    
  3. Inserting some requires into pyproject.toml, as in this issue :

       [build-system]
       requires = [
           "setuptools",
           "Cython>=0.27.3",  # Note: sync with setup.py
           "numpy"
       ]
       build-backend = "setuptools.build_meta"
    
  4. python setup.py install

  5. pip install .

With the changes, the installation seems to work.
But when I try to import the distance module via
import traj_dist.distance as tdist I get the following error:

      (synth_privacy_evaluation) ➜  privacyrisk git:(main) ✗ python example.py
      Traceback (most recent call last):
        File "/Users/alex/PycharmProjects/synth_privacy_evaluation/privacyrisk/example.py", line 12, in <module>
          import privrisk
        File "/Users/alex/PycharmProjects/synth_privacy_evaluation/privacyrisk/privrisk.py", line 10, in <module>
          import traj_dist.distance as tdist
        File "/Applications/anaconda3/envs/synth_privacy_evaluation/lib/python3.10/site-packages/traj_dist/distance.py", line 3, in <module>
          from .cydist.sspd import c_e_sspd, c_g_sspd
        File "traj_dist/cydist/sspd.pyx", line 8, in init traj_dist.cydist.sspd
      ModuleNotFoundError: No module named 'basic_euclidean'

I tried to change the imports and add paths manually, but that didn't work either. So if you could help me, that would be really nice!

@iurm
Copy link

iurm commented Jan 3, 2024

Hello, I faced the same issue and solved it. It seems that if you are using Python 3, you need to import like this:

from .basic_euclidean import c_point_to_trajectory

instead of

from basic_euclidean import c_point_to_trajectory

https://copyprogramming.com/howto/module-not-found-error-when-importing-a-cython-pyd-file

So, in sspd.pyx and all other .pyx files in cydist directory, just add a dot . before every basic_euclidean and basic_geographical import.
Hope this helps.

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

No branches or pull requests

2 participants