Closed AngelEzquerra closed 4 years ago
Can you please provide:
I'm sorry this happened, I made sure to test on Windows 10 x86_64 MSVC so I'm sure its related to an architecture mismatch of some sort.
Also, just a side note, the architecture of the Nim compiler, C compiler, and Python have to match (all be x86 or all be x64).
I guess the problem might be that my python version is 32 bits while my windows and nim versions are 64 bit:
Version of Windows (8/10 x86 or x64, etc.)
Windows 10 Enterprise (x64), version 1709 4.00
Version of C compiler (MSVC vs MingW, etc.) gcc version 6.3.0 (x86_64-win32-seh-rev1, Built by MinGW-W64 project)
Full stack trace Not sure what you need here
Version of Nimporter (pip show nimporter)
Name: nimporter
Version: 1.0.0
Summary: Compile Nim extensions for Python when imported!
Home-page: http://github.com/Pebaz/Nimporter
Author: http://github.com/Pebaz
Author-email: None
License: MIT
Location: c:\python\lib\site-packages
Requires:
Required-by:
Nim compiler version info (x86 or x64, etc.)
Nim Compiler Version 1.2.0 [Windows: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 7e83adff84be5d0c401a213eccb61e321a3fb1ff active boot switches: -d:release
- Python version info (x86 or x64, MSVC or GCC, etc.)
`Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32`
If the problem is due to this mismatch it would be nice if the error message could somehow be improved (e.g. it could provide a hint indicating that there might be a 32/64 bit build mismatch between python and the nim generated dll).
I'll try with a 64 bit python and report back.
Thank you for providing all these details!
I would wager that the 32 vs 64 bit is definitely the issue.
I have updated Nimporter to be able to provide this information (if possible) when it cannot import something that it just compiled.
So error messages have been improved for exactly this situation.
If you are interested, you could pull master
and then reimport to see the new error message and then try with 64 bit after to test.
Oh, also, I just saw something else. The compiler used to build Python must match the compiler used by Nim. Right now, your Python is MSVC (the MSC in the Python version means MSVC, I have no idea why they didn't just use "MSVC") but your system C compiler is GCC. To use Nim along with Python, you will need to have a C compiler that matches Python (both the architecture (x86 or x64) and the actual compiler (MSVC/Clang/GCC). Sorry it's a bit fiddly, but the cool thing about Nimporter is that when you ship a binary distribution of your library to an end user, they won't need to have a Nim or C compiler installed!
I will go ahead and mark this as closed as I am assuming that you were able to get it to work.
I just tried to follow the example on the readme file (creating a simple nim_math.nim file and a python nimporter_test.py file to use nim_math). I got the following error on my Windows computer:
I'm using python 3.7.1 and nim 1.2.0. I installed nimporter using "pip install nimporter". I installed nimpy using "nimble install nimpy".