knaidoo29 / mistree

A python package for constructing and analysing minimum spanning trees.
MIT License
48 stars 22 forks source link

Error of Installation of MisTree using Google Colab after November Update #27

Open Kennyc222 opened 2 days ago

Kennyc222 commented 2 days ago

Here is a problem when I intended to install Mistree on GOogle Colab...Now I'm unable to use it at all!

Screen Shot 2024-11-21 at 11 11 04 AM

I suspected it is on your side, may you please fix it? Thanks

Kenny

knaidoo29 commented 2 days ago

There's a whole bunch of issues that could be at work here. I need more details to help you. What python version are using? What numpy version? Is a fortran compiler available?

The easiest way to get around all these issues is to clone the pure_python branch of mistree from github and install it by running pip install . in the cloned directory. You will then import as import mistree_pp as mist.

Kennyc222 commented 2 days ago

According toe Google Colab itself, the version of python is 3.10

py3.10

Numpy is 2.13

numpy 2.1.3

And I don't think Fortrain complier at all.

import mistree_pp as mist doesn't work after pip install it

knaidoo29 commented 2 days ago

So you didn't get any errors when installing? Can you try doing it again and sending me what it outputs while it installs?

Kennyc222 commented 2 days ago

actually, I still get error when I even tried to install pure python...now I can't use your package anymore....

knaidoo29 commented 2 days ago

If you show me what it says you might be able to.

knaidoo29 commented 2 days ago

Another thing you can do is use python 3.8, and a numpy version < 1.23.

knaidoo29 commented 2 days ago

I am able to get it running on google colab. You need to do the following:

  1. Clone the pure_python repository into a specific folder
    !mkdir software
    !mkdir software/mistree
    !git clone -b pure_python https://github.com/knaidoo29/mistree.git software/mistree
  2. Install older versions of setuptools and numpy (in both instances it might ask you to restart):
    !pip install numpy==1.22
    !pip install setuptools==59.8.0
  3. Install mistree pure_python branch
    !python software/mistree/setup.py build
    !python software/mistree/setup.py install
  4. Test it works:
    
    import numpy as np
    import matplotlib.pylab as plt
    import mistree_pp as mist

x = np.random.random_sample(100) y = np.random.random_sample(100)

mst = mist.GetMST(x=x, y=y)

d, l, b, s, l_index, b_index = mst.get_stats(include_index=True)

plt.figure(figsize=(7., 7.))

plotting nodes:

plt.scatter(x, y, s=10, color='r')

plotting MST edges:

plt.plot([x[l_index[0]], x[l_index[1]]], [y[l_index[0]], y[l_index[1]]], color='k')

plt.xlim(0., 1.) plt.ylim(0., 1.) plt.xlabel(r'$X$', size=16) plt.ylabel(r'$Y$', size=16) plt.tight_layout() plt.show()