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

[BUG]: pip install on windows failing #65

Closed
asreimer opened this issue Mar 1, 2021 · 8 comments
Closed

[BUG]: pip install on windows failing #65

asreimer opened this issue Mar 1, 2021 · 8 comments
Labels
Milestone

Comments

@asreimer
Copy link
Collaborator

asreimer commented Mar 1, 2021

Describe the bug

pip install . doesn't work out of the box with Windows 10 and the mingw32 compiler.

To Reproduce
Steps to reproduce the behavior:

  1. Grab this commit: git clone git+https://github.com/aburrell/apexpy.git@4a5b2d696b1c905b77e4115cbe9438f41c0c6740 (This is the latest, about to be merged in for 1.1.0 release)

  2. Try to pip install . and then try importing import apexpy in a python shell and get this result:

    Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import apexpy
    C:\tools\miniconda3\envs\py37\lib\site-packages\apexpy\apex.py:19: UserWarning: fortranapex module could not be imported, so apexpy probably won't work. Make sure you have a gfortran compiler. Wheels installation assumes your compiler lives in /opt/local/bin" assumes your compiler lives in /opt/local/bin"]))
    Traceback (most recent call last):
    File "", line 1, in
    File "C:\tools\miniconda3\envs\py37\lib\site-packages\apexpy_init_.py", line 3, in
    from .apex import Apex, ApexHeightError
    File "C:\tools\miniconda3\envs\py37\lib\site-packages\apexpy\apex.py", line 20, in
    raise err
    File "C:\tools\miniconda3\envs\py37\lib\site-packages\apexpy\apex.py", line 14, in
    from . import fortranapex as fa
    ImportError: DLL load failed: The specified module could not be found.

Expected behavior
The pip install command should work fine.

Computer (please complete the following information):
Windows 10, miniconda python3.7 with mingw32 compiler installed.

@asreimer asreimer added this to the 1.1.1 Release milestone Mar 2, 2021
@asreimer asreimer added the bug label Mar 2, 2021
@asreimer
Copy link
Collaborator Author

asreimer commented Mar 2, 2021

edit: redacted

@asreimer
Copy link
Collaborator Author

asreimer commented Mar 2, 2021

The original issue was on my end. It seems that I can get everything working now and am getting the same results identically in both windows and linux now.

edit: I updated this issue for what I found along the way.

This testing was useful though because I found that I cannot install apexpy without adding:

[build_ext]
mingw32 

to setup.cfg. This directly impacts #59. I haven't figured out an algorithmic fix yet. At the very least, maybe we need to add instructions in the docs?

What do you think @aburrell?

@asreimer asreimer changed the title [BUG]: Output seems to be OS dependent [BUG]: pip install on windows failing Mar 2, 2021
@aburrell
Copy link
Owner

aburrell commented Mar 2, 2021

Hmmm... and I am guessing from this command that there's no 32/64 agnostic command? My first instinct is to say, "let's create a branch and I'll upload a testable pip release candidate for you". But we need to make sure the setup config won't break appveyor or people with 64-bit systems, or are not on Windows!

I think adding instructions may be the way to go. I saw this example for using/abusing pip. Does it work for you?

# Specifying mingw32
pip install --global-option build_ext --global-option --compiler=mingw32 apexpy

# Specifying Visual C++
pip install --global-option build_ext --global-option --compiler=msvc apexpy

Above solution from: https://stackoverflow.com/questions/3297254/how-to-use-mingws-gcc-compiler-when-installing-python-package-using-pip

Also, did you try the pip install from TestPyPi? That will get you the current release candidate. From your statement above it looks like you didn't, but am also not sure if it will matter in this instance.

@asreimer
Copy link
Collaborator Author

asreimer commented Mar 2, 2021

After some sleep, I tried again. I had already tried the suggested command, specifically this:

pip install --global-option build_ext --global-option --compiler=mingw32 .

but it doesn't work. Looking at the logs, it seems to try to build all the dependencies in pyproject.toml first and that's what's causing the problem:

Processing c:\users\xxxx\desktop\git\apexpy
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:

So if I tell pip to ignore PEP 517, that fixes things:

pip install --no-use-pep517 --global-option build_ext --global-option --compiler=mingw32 .

So adding pyproject.toml fixed some things, but it does weird things when specifying custom build args? This should also work for installing from pypi later. Installing from TestPyPi, this works:

pip install --no-use-pep517 --global-option build_ext --global-option --compiler=mingw32 --index-url https://test.pypi.org/simple/ apexpy==1.1.0

So probably the best solution to all of this is just to document this idiosyncrasy for windows users?

@aburrell
Copy link
Owner

aburrell commented Mar 2, 2021

So probably the best solution to all of this is just to document this idiosyncrasy for windows users?

Yes, I think that's the best way forward.

@asreimer
Copy link
Collaborator Author

asreimer commented Mar 2, 2021

Sounds good. I'll make a commit to the documentation later today. Thanks!

@asreimer
Copy link
Collaborator Author

asreimer commented Mar 3, 2021

Looks like the best solution for Windows users might be to do this: https://wiki.python.org/moin/WindowsCompilers#GCC_-_MinGW-w64_.28x86.2C_x64.29

I've tested this and I can now simply run pip install . from within the git repo. Also, pip install --no-use-pep517 --global-option build_ext --index-url https://test.pypi.org/simple/ apexpy==1.1.0 works, but only if I include the --no-use-pep517 flag.

@gregstarr
Copy link
Contributor

I am on Windows 11 and was having trouble installing apexpy as part of a conda environment.yml file. There were no errors during installation but I got the ImportError: DLL load failed: The specified module could not be found..

Everything appears to work if I take the following steps:

  1. conda create -n env
  2. conda activate env
  3. conda install numpy
  4. pip install apexpy
  5. conda env update -f environment.yml

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

No branches or pull requests

3 participants