spirit-code / ovf

OVF (OOMMF Vector Field file format) parser library with C API and language bindings
MIT License
8 stars 2 forks source link

Not able to pip install package in anaconda on windows 10 #13

Open Joost-A opened 4 years ago

Joost-A commented 4 years ago

I tried to install the package with the anaconda prompt on a windows 10 system using the command 'pip install ovf'. I recieved the following error message:

Collecting ovf
  Using cached ovf-0.4.3.tar.gz (492 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-0ueof6kx\\ovf\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-0ueof6kx\\ovf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-install-0ueof6kx\ovf\pip-egg-info'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-0ueof6kx\ovf\
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-0ueof6kx\ovf\setup.py", line 123, in <module>
        long_description = read(README),
      File "C:\Users\user\AppData\Local\Temp\pip-install-0ueof6kx\ovf\setup.py", line 45, in read
        with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f:
      File "c:\anaconda3\lib\codecs.py", line 897, in open
        file = builtins.open(filename, mode, buffering)
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-0ueof6kx\\ovf\\..\\README.md'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I then tried to clone the respository with git. I gave the anaconda prompt the command: "pip install git+https://github.com/spirit-code/ovf.git" and got the following error message.

Collecting git+https://github.com/spirit-code/ovf.git
  Cloning https://github.com/spirit-code/ovf.git to c:\users\user\appdata\local\temp\pip-req-build-k2mltrb6
  Running command git clone -q https://github.com/spirit-code/ovf.git 'C:\Users\user\AppData\Local\Temp\pip-req-build-k2mltrb6'
    ERROR: Command errored out with exit status 1:
     command: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-build-k2mltrb6\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-build-k2mltrb6\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-req-build-k2mltrb6\pip-egg-info'
         cwd: C:\Users\user\AppData\Local\Temp\pip-req-build-k2mltrb6\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\anaconda3\lib\tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-build-k2mltrb6\\setup.py'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Details; -python version: 3.6 -pip version: 20.0.2 -operating system : 64 bit windows 10 -git version: 2.25.1.windows.1

GPMueller commented 4 years ago

To be honest I don't know what is necessary to support this kind of package with conda... conda has always given me problems. Can you try to manually build the package on your machine instead of downloading it from PyPI?

cd python
python setup.py sdist bdist_wheel;
Joost-A commented 4 years ago

Thank you for your quick response. If I try building it manually as you suggested I get the following error message:

C:\Users\user\ovf-master\python>python setup.py sdist bdist_wheel;
Traceback (most recent call last):
  File "setup.py", line 49, in <module>
    META_FILE = read(META_PATH)
  File "setup.py", line 45, in read
    with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f:
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\codecs.py", line 898, in open
    file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\ovf-master\\python\\ovf\\__init__.py'

I looked around for the __init__.py file, but I couldn't find it so I (with my basic python knowledge) am not quite sure why it is called. Any help is appreciated.

MSallermann commented 4 years ago

The __init__.py file is automatically generated by cmake (https://cmake.org). Here are the steps to build from source, that worked for me:

  1. Run cmake on the source directory. You can use the cmake GUI for that. Make sure to set OVF_BUILD_PYTHON_BINDINGS=ON.
  2. CMake will generate a Visual Studio solution ovf.sln (and the __init.py__ file). Open the solution in Visual Studio and build it from there. This will create the ovf.dll file, which I copied to the ovf\python directory.
  3. Now you can perform the steps posted by gmueller.

    cd python python setup.py sdist bdist_wheel;

GPMueller commented 3 years ago

Dear @Joost-A, were you able to resolve your issue? If so, I'd like to close this.

For reference, the Python-package build in the CI is currently: https://github.com/spirit-code/ovf/blob/ba6cab7a6627254801ebc4966af3fe53c0c3fff7/.github/workflows/ci.yml#L135-L159