MattWillFlood / EntropyHub

An open-source toolkit for entropic data analysis.
https://www.entropyhub.xyz
Apache License 2.0
146 stars 19 forks source link

installation with Anaconda #2

Closed eleonora-mont closed 1 year ago

eleonora-mont commented 1 year ago

Hi Matt,

I am trying to install the EntropyHub package with Anaconda, but when I type it in the search package bar, I cannot find it. I was trying with the pip command and it seemed to work but then when I imported my library, it said the EntropyHub was not accessed. I would have downloaded it with the zip file but when I click on the following to download it: EntropyHub-0.2.tar, I get a file that I cannot open. Any suggestion to fix this?

Thanks, Eleonora

MattWillFlood commented 1 year ago

Hi @eleonora-mont!

Thanks for your question, I'll do my best to help you out :) Before going any further, I would strongly recommend that you have a go at installing EntropyHub using the steps outlined on the EntropyHub website, in the EntropyHub paper or in section 2.2 of the EntropyHub user guide.

Now, back to your problem. Just to be clear, conda and pip are different package management systems. (See here and here for more info) So if you install a package with pip, it won't appear in the Anaconda package list. To the best of my knowledge, only packages installed with conda will appear in the Anaconda Navigator package list.

To see what packages you have installed on your system, either with pip or conda, search for the anaconda prompt and open it; it will look like a terminal. On the command line enter: conda list to see packages installed with conda - like this pip list to see packages installed with pip - like this

If EntropyHub (case-sensitive) doesn't appear in either list, then it's not installed.

To help you further, I need a little more info... What IDE or software do you use for programming in Python? When you downloaded the EntropyHub-0.2.tar.gz file, did you make sure to unzip it before trying to install? Can you share a screenshot of the error message that appears when you try to import EntropyHub, where it says that it can't access it?

Feel free to contact me at help@entropyhub.xyz if it's easier to respond via email rather than here.

Thanks, Matt

EDIT I have not yet uploaded EntropyHub to Anaconda.org, so installation via conda is not yet possible. I will fix this as soon as possible, but for now installation should work with pip.

eleonora-mont commented 1 year ago

Hi Matt,

I managed to install EntropyHub with Anaconda prompt but I can see that you still need to upload EntropyHub on Anaconda, which is why when I imported the library, it said to me that it couldn't be accessed. Hope to have it available soon :)

Thanks, Eleonora

MattWillFlood commented 1 year ago

Hi @eleonora-mont,

Good to hear that you managed to install EntropyHub. Can you confirm that it is now working? If it's installed, then it should be work.

Thanks, Matt

eleonora-mont commented 1 year ago

Hi Matt,

So it does say that EntropyHub is in my conda list, however when I import the library, EntropyHub is darker green compared to pandas and numpy (see image) and when I move the cursor over it, it gives me an error message saying that the library is not accessed. I don’t know whether this might be due to EntropyHub not being uploaded to Anaconda or if I made some mistakes during the download and import. I also tried to write due lines of code to calculate base entropy on my time serie data, python does not gives me an error per se, but it does not even print my results, which I was thinking might be due to the library not working.

error
MattWillFlood commented 1 year ago

Hi Eleonora,

If you run import EntropyHub and don't get an error, that's a good sign. What happens when you enter:

import EntropyHub as EH
EH.greet()

...?

If you run the following lines of code

import EntropyHub as EH
from matplotlib.pyplot import imshow, show
X = EH.ExampleData('mandelbrot_Mat');
imshow(X, cmap = 'hot'), show()
FE2D = EH.FuzzEn2D(X, m = (8, 5), tau = 2, Fx = 'linear', r = 0, Logx = 3)

and then print the value of FE2D, you should get FE2D = 0.00159093. ** You will need to be connected to the internet in order to run EH.ExampleData()

eleonora-mont commented 1 year ago

Hi Matt,

By entering the first two lines, I get this, which is a good sign:

g

When I run the other lines of code, I got this error message (I am connected to the wifi), which however does not relate to the function of the library.

err

To be honest, it seems it should work. I will try it again today.

Thanks, Eleonora

MattWillFlood commented 1 year ago

Hi Eleonora,

The fact that EH.greet() prints the EntropyHub logo means that EntropyHub is installed and imported correctly. The EH.ExampleData() function may not work if your internet firewall blocks downloads from external sites. Regardless, you should be up and running now. Try using some functions with whatever data you have to see if the entropy values are returned :)

eleonora-mont commented 1 year ago

Hi Matt,

I am going to disturb you just once more.

I just tried a simple example for my .csv file, containing n>10 rows and 1 column, with this code:

import EntropyHub as EH import numpy as np import pandas as pd from matplotlib.pyplot import imshow, show X = pd.read_csv ('rh_limb_accx.csv'); results = EH.ApEn(X, m = 1, tau = 1, r = 0.2*np.std(X), Logx = np.exp(1)) print (results)

However, I am receiving this error message about the argument inputs so I was wondering if you could explain briefly to me the arguments and whether there are fixed values to use.

w

Sorry this is my first time calculating entropy so I am not really an expert :)

Thanks again, Eleonora

MattWillFlood commented 1 year ago

Hi Eleonora,

Your input data (X) should be a numpy 1D array, not a pandas data frame. If you convert your data to a numpy array using pd.DataFrame.to_numpy() it should work. Furthermore, make sure that your r parameter is positve value, either an int or a float. If your data (X) has a value that is neither an int or float (e.g. NaN), this could also cause an error.

Let me know if this works :)

Thanks!

ad045 commented 5 months ago

Hi Matt,

Importing EntropyHub does not work for me - do you have any advice on what I could do? I installed EntropyHub with pip, and it seems to have worked (output below for pip list). However, when I try to import it in a python script, I get the following error:

(clean) dena@ceres:~/.local/share/jupyter/runtime$ python3
Python 3.12.0 | packaged by conda-forge | (main, Oct  3 2023, 08:43:22) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import EntropyHub
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'EntropyHub'

(clean) dena@ceres:~/.local/share/jupyter/runtime$ pip list
Package                   Version                  Editable project location
------------------------- ------------------------ ----------------------------------------------------
[...]
EntropyHub                1.0.1
[...]

Do you have any advice on what to try?

Best, Adrian

MattWillFlood commented 5 months ago

Hi @ad045 ,

At first glance it would seem that this is not an EntropyHub issue, but related to how you have set up pip on your system...

Can you provide some more info please? Are you using a programming IDE? (e.g. Spyder, Pycharm)

ad045 commented 5 months ago

Hi Matt,

Thank you for your swift reply! It's good to know that the issue will be most likely in the setup of pip.

Yes, I am using a programming IDE (Visual Studio Code). I can, however, recreate the issue directly in the terminal. I have attached the output for creating a new conda environment, installing EntropyHub, and then trying to import EntropyHub in python3:

(base) dena@ceres:~$ conda create --name testing_env_entropyhub
Collecting package metadata (current_repodata.json): done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 4.10.3
  latest version: 24.3.0

Please update conda by running

    $ conda update -n base -c defaults conda

## Package Plan ##

  environment location: /u/home/dena/.conda/envs/testing_env_entropyhub

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate testing_env_entropyhub
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(base) dena@ceres:~$ conda activate testing_env_entropyhub
(testing_env_entropyhub) dena@ceres:~$ pip install EntropyHub
Defaulting to user installation because normal site-packages is not writeable
Collecting EntropyHub
  Downloading EntropyHub-1.0.1-py3-none-any.whl (8.1 kB)
Requirement already satisfied: scipy in /opt/anaconda3/lib/python3.9/site-packages (from EntropyHub) (1.7.1)
Collecting EMD-signal
  Downloading EMD_signal-1.6.0-py3-none-any.whl (74 kB)
     |████████████████████████████████| 74 kB 2.1 MB/s
Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.9/site-packages (from EntropyHub) (1.20.3)
Requirement already satisfied: requests in /opt/anaconda3/lib/python3.9/site-packages (from EntropyHub) (2.26.0)
Requirement already satisfied: matplotlib in /opt/anaconda3/lib/python3.9/site-packages (from EntropyHub) (3.4.3)
Collecting pathos>=0.2.1
  Downloading pathos-0.3.2-py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 196 kB/s
Collecting tqdm<5.0,>=4.64.0
  Downloading tqdm-4.66.2-py3-none-any.whl (78 kB)
     |████████████████████████████████| 78 kB 6.7 MB/s
Collecting pox>=0.3.4
  Downloading pox-0.3.4-py3-none-any.whl (29 kB)
Collecting ppft>=1.7.6.8
  Downloading ppft-1.7.6.8-py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 4.5 MB/s
Collecting dill>=0.3.8
  Downloading dill-0.3.8-py3-none-any.whl (116 kB)
     |████████████████████████████████| 116 kB 57.8 MB/s
Collecting multiprocess>=0.70.16
  Downloading multiprocess-0.70.16-py39-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 57.7 MB/s
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/anaconda3/lib/python3.9/site-packages (from matplotlib->EntropyHub) (1.3.1)
Requirement already satisfied: pyparsing>=2.2.1 in /opt/anaconda3/lib/python3.9/site-packages (from matplotlib->EntropyHub) (3.0.4)
Requirement already satisfied: pillow>=6.2.0 in /opt/anaconda3/lib/python3.9/site-packages (from matplotlib->EntropyHub) (8.4.0)
Requirement already satisfied: python-dateutil>=2.7 in /opt/anaconda3/lib/python3.9/site-packages (from matplotlib->EntropyHub) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /opt/anaconda3/lib/python3.9/site-packages (from matplotlib->EntropyHub) (0.10.0)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.9/site-packages (from cycler>=0.10->matplotlib->EntropyHub) (1.16.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/anaconda3/lib/python3.9/site-packages (from requests->EntropyHub) (1.26.7)
Requirement already satisfied: idna<4,>=2.5 in /opt/anaconda3/lib/python3.9/site-packages (from requests->EntropyHub) (3.2)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.9/site-packages (from requests->EntropyHub) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/anaconda3/lib/python3.9/site-packages (from requests->EntropyHub) (2.0.4)
Installing collected packages: dill, ppft, pox, multiprocess, tqdm, pathos, EMD-signal, EntropyHub
  WARNING: The script tqdm is installed in '/u/home/dena/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed EMD-signal-1.6.0 EntropyHub-1.0.1 dill-0.3.8 multiprocess-0.70.16 pathos-0.3.2 pox-0.3.4 ppft-1.7.6.8 tqdm-4.66.2
(testing_env_entropyhub) dena@ceres:~$ python3
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import EntropyHub
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'EntropyHub'
>>>`

Could you let me know, if there is any kind of information that would be valuable? I'm also faily new to programming, and it's still hard for me to judge which information is sensible to send. Best, Adrian

MattWillFlood commented 5 months ago

So from what I can tell, you are using your system command prompt in VScode. Thus, the error will naturally occur in both as it is the same prompt, just in a different window.

It could be that you are you using python and/or pip that were installed with conda. (Did you install python separately?) Conda is naturally configured to install and look up packages in a specific location. If using python outside of conda (in your case, with VScode and not say Spyder) imports can fail because the location where packages are stored is not on your system path. Try this in your prompt:

  1. Enter
    (base) > pip show EntropyHub

    See where the package is located. It should look like this:

    Name: EntropyHub
    Version: 1.0.1
    Summary: An open-source toolkit for entropic time series analysis.
    Home-page: https://www.EntropyHub.xyz
    Author: Matthew W. Flood
    Author-email: info@entropyhub.xyz, help@entropyhub.xyz
    License: Apache 2.0
    Location: c:\users\...\appdata\roaming\python\python39\site-packages
    Requires: EMD-signal, matplotlib, numpy, requests, scipy
    Required-by:
  2. Switch to python and look at your system path, like so:
    (base) > python
    >>> import sys
    >>> sys.path

    If the location of the pip-installed package (i.e. EntropyHub) is not in the list of locations in the python path, then it won't be found when importing... You'd have to update your system path to include the location of stored packages.

This appears to be a very common issue (at least from online searches) to which there is unique solution. The answer here is the standard one, but it may not work.

Let me know how you get on :)

MattWillFlood commented 5 months ago

@ad045 - Just a quick update

It seems that the EntropyHub package didn't build properly when I uploaded it to PyPi. Not sure why, but the code was not incorporated in the build... So the problem is not on your side, apologies for that... Totally my bad.

I'll be uploading a new package version in the coming days, so you will be able to install EntropyHub fully (and with new features!)

Thanks! Matt

MattWillFlood commented 5 months ago

Hi @ad045 👋🏼 👋🏼

This problem should be fixed now 🤞🏼 🙏🏼 I have uploaded a new release of EntropyHub (v2.0) on PyPi 🚀 🎆

You should be able to install and run EntropyHub v2.0 as follows:

(base) user/.../mydir : pip install EntropyHub==2.0
(base) user/.../mydir : python

>>> import EntropyHub as EH
>>> EH.greet()

         ___  _   _  _____  _____  ____  ____  _     _
        |  _|| \ | ||_   _||     \|    ||    || \   / |   ___________
        | \_ |  \| |  | |  |   __/|    ||  __| \ \_/ /   /  _______  \
        |  _|| \ \ |  | |  |   \  |    || |     \   /   |  /  ___  \  |
        | \_ | |\  |  | |  | |\ \ |    || |      | |    | |  /   \  | |
        |___||_| \_|  |_|  |_| \_||____||_|      |_|   _|_|__\___/  | |
         _   _  _   _  ____                           / |__\______\/  |
        | | | || | | ||    \     An open-source      |  /\______\__|_/
        | |_| || | | ||    |     toolkit for         | |  /   \  | |
        |  _  || | | ||    \     entropic time-      | |  \___/  | |
        | | | || |_| ||     \    series analysis     |  \_______/  |
        |_| |_|\_____/|_____/                         \___________/

        Please use the following citation on any scientific outputs achieved with the help of EntropyHub:

        Matthew W. Flood,
        EntropyHub: An Open-Source Toolkit for Entropic Time Series Analysis,
        PLoS One 16(11):e0259448 (2021),
        DOI: 10.1371/journal.pone.0259448

        www.EntropyHub.xyz

If you are still experiencing issues, please let me know 😊 👍🏼

AashishKhilnani commented 5 months ago
image

Still facing the same issue. Please see!

MattWillFlood commented 5 months ago

Have you tried running this outside Jupyter?

ad045 commented 5 months ago

Thank you so much, @MattWillFlood, for the new release! 🚀