AguaClara / aguaclara

An open-source Python package for designing and performing research on AguaClara water treatment plants.
https://aguaclara.github.io/aguaclara/
MIT License
24 stars 13 forks source link

Installation error building wheels for numpy. #325

Closed WPennock closed 1 month ago

WPennock commented 3 months ago

I was trying to install aguaclara within a newly-installed Anaconda environment. When I did pip install aguaclara within the Anaconda Prompt, I got:

ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

I looked it up, and this seems to be a backwards compatibility issue with Numpy. My current installation has Numpy 1.26.4, but the pyproject.toml for aguaclara has version 1.22.1 specified. I am thinking this means that the version of the aguaclara package needs to be updated to current package versions. I have seen others facing this issue in Windows 11. For reference, my environment is:

@fletchapin @monroews Is this package still being maintained? Is there a way I can help?

monroews commented 1 month ago

We don't have anyone in charge of maintaining this code base. I can happily give you editing permission to update the code!

WPennock commented 1 month ago

I would be happy to do this, since it falls under the scope of my work and our lab group and my classes use it fairly frequently, so I get plenty of feedback on issues. However, it has been some years since I looked at how the testing, versioning, and documentation. Is there any resource I can consult or person I can talk to in order to make sure I carry this on effectively?

WPennock commented 1 month ago

There was a developer guide (guide-dev), but it appears that link is now broken. Is there somewhere I can find this, @monroews?

[Edit: I found it here]

monroews commented 1 month ago

if you proceed to update the code please fix the link too!

WPennock commented 1 month ago

Thank you, @monroews!

I am afraid I am struggling to set up my local environment as per the guide, and I believe it is the issue of dependencies again. I have no trouble creating the local Git repository, but I run into issues when I try to make the local aguaclara repository the package Python on my machine will run.

If I try to do this globally (pip install --editable . -U --user), I get

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
numba 0.54.1 requires numpy<1.21,>=1.17, but you have numpy 1.22.1 which is incompatible.

For context, aguaclara 0.3.4 requires numpy 1.22.1, so this seems to be an inconsistency in the dependencies although I can confirm that aguaclara works for me. I do want to make sure I am using version 0.3.4. Is there a way to test that in Python? For other packages like numpy, you can enter print(np.__version__). Is there a similar approach for aguaclara?

If I try to do this for the virtual environment (pipenv install --dev -e .), I get

 ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to inspect the versions actually installed in the virtualenv.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for scipy

I'm hoping this is just that I am not familiar with doing this, but my understanding is that the dependencies aguaclara 0.3.4 requires are several years out of date and not compatible with my current python environment. However, I understand pyenv is supposed to help work around this.

@HannahSi and @fletchapin would you be willing to point me in the right direction so that I can begin keeping this package updated?

monroews commented 1 month ago

my only advice is to use chatGPT to guide you. I think they would provide good advice for this problem.

fletchapin commented 1 month ago

Hi @WPennock sorry I am just seeing this now but I can take a look this weekend at the dependencies! I don't think it has been actively maintained but once the dependencies are updated if you want to take it over that would be great.

fletchapin commented 1 month ago

When I just installed the package with pip install -e . after launching a virtual environment with pipenv shell I did not get an error. I believe the issue is you are not using a fresh environment since the dependency clash is with numba==0.54.1 and numba is not an aguaclara dependency.

To avoid this always make sure to create a new virtual environment for every package!

fletchapin commented 1 month ago

@WPennock if you have any remaining issues let me know and I will re-open it, but otherwise I am closing this issue

WPennock commented 1 month ago

Thank you, @fletchapin! I have trouble even with pipenv shell entered first, although I hadn't been doing that, and I think that would be good to add to the developer guide. For reference, I get references to ssl and urllib3, although I am sure I will eventually be able to work out the specifics.

WARNING:pipenv.patched.pip._internal.models.search_scope:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

...

[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to inspect the versions actually installed in the virtualenv.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for urllib3

I can keep working on getting my local repository working, but the larger reason for this issue is that I do not believe people running Windows 11 can pip install aguaclara, and I wonder if that may be true for other operating systems as well. I think the dependencies need to be updated for the package.

Would that basically require looking up current versions of packages that are stable and changing those version numbers in setup.py? I found this page and plan to work through it, but I wanted to make sure I'm working on this in a way that is consistent with what has been done in the past.

fletchapin commented 1 month ago

When I searched the SSL error, I saw that it may be an issue with the way your SSL certificate is installed on Windows: https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

I have installed the package for Linux, Mac, and Windows (albeit Windows 10 and Python 3.10) so I would be surprised if it does not work on your machine. Perhaps I can try to install it on a VM with Windows 11 and Python 3.11 to double check

monroews commented 1 month ago

I'd be very interested in knowing if the AguaClara code still works well in Colab or other online versions of Jupyter notebooks.

fletchapin commented 1 month ago

@WPennock like you said, we can change the version of numpy it requires to unpin it from 1.22.1. After looking at the Colab notebook it installs, but with a warning, so maybe some packages for the newer versions of Python are incompatible with that old numpy version.

Screenshot 2024-08-19 at 1 54 22 PM Screenshot 2024-08-19 at 1 54 08 PM

With that said, the import works correctly despite the warning and you are able to use the aguaclara package in Colab currently.

Screenshot 2024-08-19 at 1 56 33 PM
WPennock commented 1 month ago

@fletchapin Thank you for looking into all of this! Okay, I am glad that aguaclara is working in all of those environments.

I am not sure why my student and I had trouble on Windows 11 machines. The errors that were thrown related to the version of numpy, so I suspect that requiring a more recent version of numpy or using * to not specify a version may solve the issues we had.

I still cannot install on my laptop directly, and I believe that this is because I have Python 3.12. I get similar errors to those shown here. The answer suggested that numpy 1.26.4 is required for Windows 12. I am able to install aguaclara in a virtual environment (thank you for your help with this!) if I take out the numpy version requirement. I'm even able to run pipenv run pytest (which incidentally has failures for functions in onshape_parser.py and procoda_parser.py, which I suspect are due to the new numpy version). I will see if I can eliminate these errors and create a pull request for changing the requirement to 1.26.4.

fletchapin commented 1 month ago

Hi @WPennock I've been busy on vacation but I just wanted to check if you had any further questions about this issue or help creating a PR