Closed x3zou closed 2 months ago
Could you try installing from the GitHub repository directly? We made some updates to address deprecations (see that first warning in your log) but they weren't pushed to PyPI yet. I.e., try this:
git clone https://github.com/tbenthompson/okada_wrapper.git
pip install ./okada_wrapper/
@tbenthompson I just noticed that the README contains old "manual installation" instruction that refer to setup.py
that should be modified before the PyPI release (happy to do that).
Cheers
Thanks for the quick reply! I tried using git clone and then pip install but I got the following errors:
pip install ./okada_wrapper/ Processing ./okada_wrapper Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [12 lines of output]
meson setup /Users/x3zou/okada_wrapper /Users/x3zou/okada_wrapper/.mesonpy-m92037fi -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/Users/x3zou/okada_wrapper/.mesonpy-m92037fi/meson-python-native-file.ini The Meson build system Version: 1.4.0 Source dir: /Users/x3zou/okada_wrapper Build dir: /Users/x3zou/okada_wrapper/.mesonpy-m92037fi Build type: native build Project name: DC3D Project version: undefined
../meson.build:1:0: ERROR: Compiler gfortran cannot compile programs.
A full log can be found at /Users/x3zou/okada_wrapper/.mesonpy-m92037fi/meson-logs/meson-log.txt [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed
× Encountered error while generating package metadata. ╰─> See above for output.
note: This is an issue with the package mentioned above, not pip. hint: See above for details.
Something wrong with the gfortran?
Something wrong with the gfortran?
It seems so - could you upload the log file mentioned in the output? And post your versions for the two necessary compilers:
gcc --version
gfortran --version
Interestingly, the log doesn't exist. There is no such directory on my computer at all.
output of gcc --version:
Apple clang version 15.0.0 (clang-1500.3.9.4) Target: x86_64-apple-darwin23.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
output of gfortran --version:
GNU Fortran (GCC) 11.1.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I saw this thread in my email and figured I should get around to publishing a release. But I ran into this same issue! I'm on a newer gfortran (13.2.0). I need to get back to my job for now, but I'll try to come back to this soon.
It looks like this issue is probably related to https://github.com/mesonbuild/meson/issues/12282 and there's a workaround towards the end of the thread. Maybe @tobiscode would understand what to do better? I haven't yet learned my way around Meson.
Also, the log file mentioned didn't exist for me either. I'm guessing there's a flag we can pass to the build so that it doesn't delete the logs but I haven't found it yet. Or maybe something else is going on there?
I'm guessing there's a flag we can pass to the build so that it doesn't delete the logs but I haven't found it yet.
Yeah I think that's what's happening - this could fix it: https://pip.pypa.io/en/latest/cli/pip_install/#cmdoption-no-clean
With regards to the actual error, with the version output
Apple clang version 15.0.0 (clang-1500.3.9.4) Target: x86_64-apple-darwin23.4.0
I can now see that you're using MacOS. I don't have a Mac myself so I can't test it, but if it's similar to the link @tbenthompson posted, then it could be because of that. In that case, I cannot directly help with debugging/testing myself, although I'm happy to give the detailed logs a close look and suggest changes you can try.
The installation was smoothly done on my Linux remote server so I will work on that server to save some time. If I have more spare time in the future I will come back to this issue. Thanks anyway for your suggestions!!!
I experienced a similar issue today when I attempted to install okada_wrapper within a conda environment.
The main problem seems to be that "numpy.distutils is deprecated and will be removed for Python >= 3.12," as indicated on this webpage (https://numpy.org/doc/stable/reference/distutils.html#). To resolve this problem, I manually set the Python version to 3.11, which solved the issue.
Pip subprocess error:
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-uc1jvqf8/okada-wrapper_11761feab7314cae89f1853642f185f3/setup.py", line 1, in <module>
from numpy.distutils.core import setup, Extension
ModuleNotFoundError: No module named 'numpy.distutils'
[end of output]
Here's what my conda environment config file looks like:
name: env-name
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.11
- numpy
- pandas
- scipy
- matplotlib
- pip
- pip:
- okada_wrapper
I hope this information is helpful.
@sangchengfang the issue you're reporting is different (as far as I can see) and has already been fixed in https://github.com/tbenthompson/okada_wrapper/issues/8 and https://github.com/tbenthompson/okada_wrapper/issues/12 but it hasn't been pushed to PyPI yet (which is still in the works by @tbenthompson). You can use okada_wrapper
with Python >= 3.12 if you clone the repository and install from there.
Ah! Sorry to forget to do the PyPI release. It fell off my radar. I’ll do it in the next couple days.
@tobiscode OK, got it.
Release is done! I did a quick check and it worked for me. Let me know if either of you have issues.
Thanks @tbenthompson!
Just for reference though: I can install it fine but running the test script fails if I run it directly. However, when I first open Python and then call the same import routine, everything works:
~ > python ~/projects/okada_wrapper/test_okada.py
Traceback (most recent call last):
File "/home/tkoehne/projects/okada_wrapper/test_okada.py", line 1, in <module>
from okada_wrapper import dc3d0wrapper, dc3dwrapper
File "/home/tkoehne/projects/okada_wrapper/okada_wrapper/__init__.py", line 4, in <module>
from okada_wrapper.okada_wrapper import dc3d0wrapper, dc3dwrapper
File "/home/tkoehne/projects/okada_wrapper/okada_wrapper/okada_wrapper.py", line 1, in <module>
from .DC3D import dc3d0, dc3d
ModuleNotFoundError: No module named 'okada_wrapper.DC3D'
~ > python
Python 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from okada_wrapper import dc3d0wrapper, dc3dwrapper # this is the first line of test_okada.py
>>> exit()
So, I'm assuming it's again something about relative imports that could be fixed either in the source code or the test script.
Since the importing of okada_wrapper
works from my package, the functionality I need is there, and I'd keep this issue closed unless the importing isn't working for other people in general. Just figured I'd leave this comment here in case other people are wondering.
Thanks for bringing this up! The error you got is expected because you’re running the script from within the okada_wrapper folder. As a result, you’re importing the local version of okada_wrapper in that folder which hasn’t been compiled yet instead of the pip-installed version that does include the compiled components. If you copy the test_okada.py file up a couple directories and then run it, I suspect you’ll see success!
Hmm this is a bit contrary to how I thought Python handles files - I have tried running the script from my home directory and that's where I get the error message. Shouldn't in that case the home directory be the working directory, and no relative imports are necessary?..
I have tried running the script from my home directory and that's where I get the error message.
Oh yeah I missed that line at the top of your copied output! Good point. Either way, from the traceback, you can see that the import is loading up the copy of okada_wrapper
in your projects
directory:
File "/home/tkoehne/projects/okada_wrapper/okada_wrapper/__init__.py", line 4, in <module>
You might have run pip install -e .
or a similar command that installed the version projects/
as an editable package at some point? [EDIT: actually that wouldn't explain why the import works when run from the REPL. So, I'm not sure what's going wrong, but something is going wrong with where python is finding your okada_wrapper
.]
Two debugging tips if you're interested:
sys.path
to see the order of folders Python will look in when you import
a package..__file__
:❯ python
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
imp>>> import okada_wrapper
>>> okada_wrapper.__file__
'/Users/tbent/.mambaforge/envs/okadawrappertest/lib/python3.11/site-packages/okada_wrapper/__init__.py'
Yeah it really does seem that even if I execute test_okada.py
from a different folder, sys.path
contains the folder where the file is located, which then results in the wrong import order. TIL! That means there is definitely a "correct" way to write imports in the package and have testing scripts at the same time. Unless someone really needs this to work out of the box, I won't spend the time on fixing this though...
Hello Ben,
I was trying to install Okada Wrapper using the 'pip install Okada_Wrapper' but it just failed to build the wheel. I guess it could be caused by the Fortran compiler, but I can't locate where exactly the problem is. I wonder if you have any experience with this type of error. I would appreciate it very much!!! I'm so sorry that this error is just too long.
Best, Xiaoyu
pip install okada_wrapper Collecting okada_wrapper Using cached okada_wrapper-18.12.07.3.tar.gz (11 kB) Preparing metadata (setup.py) ... done Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.11/site-packages (from okada_wrapper) (1.26.4) Building wheels for collected packages: okada_wrapper Building wheel for okada_wrapper (setup.py) ... error error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [780 lines of output] /private/var/folders/bd/3zw60qqs3t531mslqqd9_kgc000t3m/T/pip-install-bub4sf_i/okada-wrapper_e1a0cec63b3f4f61872ca86b92d6c718/setup.py:1: DeprecationWarning:
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for okada_wrapper Running setup.py clean for okada_wrapper Failed to build okada_wrapper ERROR: Could not build wheels for okada_wrapper, which is required to install pyproject.toml-based projects