gurnec / btcrecover

An open source Bitcoin wallet password and seed recovery tool designed for the case where you already know most of your password/seed, but need assistance in trying different possible combinations.
GNU General Public License v2.0
1.3k stars 694 forks source link

Importing the multiarray numpy extension module failed #79

Open tigbitties opened 7 years ago

tigbitties commented 7 years ago

Most likely you are trying to run a failed build of numpy. If you're working with numpy repo, try 'git clean -xdf' (removes all files not under controle). Otherwise reinstall numpy

Original Error was: DLL load failed: 1% is not a valid Win32 application

A little advice would be greatly appreciated.

Thanks again...

gurnec commented 7 years ago

That's a strange one....

tigbitties commented 7 years ago

I'm using PyOpenCL. I have a Bitcoin Core wallet. I installed PyCrypto

gurnec commented 7 years ago

Can you try reinstalling numpy?

C:\Python27\Scripts\pip install --force-reinstall numpy

What, if anything, does this print?

C:\Python27\python -c "import numpy; print numpy.__version__"
tigbitties commented 7 years ago

C:\Python27\Scripts\pip install --force-reinstall numpy Requirment already satisfied: numpy in C:\Python27\lib\site-packages

C:\Python27\python -c "import numpy; print numpy.version"

See image: http://imgur.com/a/fndqM

gurnec commented 7 years ago

AFAIK that error only appears if there's a 32-bit/64-bit mismatch. Maybe you installed PyOpenCL, and then switched the version of Python? I'm really not sure of other ways this could happen....

Also, I gave you the wrong pip command to reinstall numpy, sorry about that... it's probably best to reinstall PyOpenCL and all of its dependencies (which includes numpy) anyways, so please try this.

First, run this to double-check which version of python you have installed, 32 or 64 bit:

C:\Python27\python -v -c "" 2>&1 | find "Python 2"

You should get one of these two lines (first one for 32-bit, second for 64): Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 32 bit (Intel)] on win32 Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32

Next, go back to the INSTALL doc and reinstall the corresponding PyOpenCL, except add --upgrade --force-reinstall after pip install. So for example, to install the 64-bit version, run this:

C:\Python27\Scripts\pip install --upgrade --force-reinstall pyopencl-2017.1.1+cl12-cp27-cp27m-win_amd64.whl

This should reinstall PyOpenCL, including numpy.

If this doesn't work, the only other thing I can think of is to start from scratch: remove all versions of Python using Apps & Features (in Windows Settings), delete the C:\Python27 folder, and try again.

If this still doesn't work, we can try some "real" debugging, but that would mean downloading some debugging tools from Microsoft and going through a whole bunch of steps... I have to warn you it's a bit of a pain....

tigbitties commented 7 years ago

I wiped and reinstalled everything... same problem. I'm going to get a little help for a local guy and hopefully a little hands on treatment will get things up and running. I'll update. Thanks for your help.

gurnec commented 7 years ago

Here's a very rough rundown of how to troubleshoot DLL load errors.

First, you need to download and run the Windows SDK installer from here. When asked which features to install, be sure to uncheck everything except Debugging Tools for Windows (otherwise you'll end up installing 2GB of extra stuff you don't need).

To start debugging:

  1. Start Global Flags (X64) (should be in the Start Menu)
  2. Go to the Image File tab
  3. Type python.exe, then press Tab ⇥
  4. Enable Show loader snaps, then click Apply
  5. Start WinDbg (X64)
  6. File menu → Open Executable..., change to the C:\Python27 folder and open python.exe
  7. In the Command window, type g, Enter ⏎
  8. Edit menu → Clear Command Output
  9. In the python.exe window, type import numpyEnter ⏎
  10. Edit menu → Copy Window Text to Clipboard, and then paste it into your preferred text editor

Search for "fail" or "error" or any non-zero return codes. For example, if I replace 64-bit numpy with 32-bit numpy, the first non-zero return code is:

1f0c:308c @ 97549812 - LdrpMinimalMapModule - ENTER: DLL name: C:\Python27\lib\site-packages\numpy\core\multiarray.pyd ModLoad: 00000000`10000000 00000000`10120000   C:\Python27\lib\site-packages\numpy\core\multiarray.pyd
1f0c:308c @ 97549812 - LdrpMinimalMapModule - RETURN: Status: 0x4000000e

And if I look up that return status in the list of NTSTATUS codes here, I get the error "The image file %hs is valid but is for a machine type other than the current machine" which is what I'd expect.

Also of use could be the list of Win32 error codes here.

Important: when you are done, be sure to disable the global flag: go back to the Global Flags window, disable Show loader snaps, then click Apply.

tigbitties commented 7 years ago

0xC000007B STATUS_INVALID_IMAGE_FORMAT

{Bad Image} %hs is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.

gurnec commented 7 years ago

Which .dll or .pyd file was being loaded (the filename may be on a line which precedes the one with the error)?

tigbitties commented 7 years ago

1a74:1a0c @ 587204941 - LdrLoadDll - ENTER: DLL name: C:\Python27\lib\site-packages\numpy\core\multiarray.pyd 1a74:1a0c @ 587204941 - LdrpLoadDllInternal - ENTER: DLL name: C:\Python27\lib\site-packages\numpy\core\multiarray.pyd 1a74:1a0c @ 587204941 - LdrpResolveDllName - ENTER: DLL name: C:\Python27\lib\site-packages\numpy\core\multiarray.pyd 1a74:1a0c @ 587204941 - LdrpResolveDllName - RETURN: Status: 0x00000000 1a74:1a0c @ 587204941 - LdrpMapViewOfSection - ENTER: DLL name: C:\Python27\lib\site-packages\numpy\core\multiarray.pyd ModLoad: 0000000010000000 0000000010128000 C:\Python27\lib\site-packages\numpy\core\multiarray.pyd 1a74:1a0c @ 587204957 - LdrpMapViewOfSection - RETURN: Status: 0x4000000e 1a74:1a0c @ 587204957 - LdrpProcessWork -
1a74:1a0c @ 587204957 - LdrpLoadDllInternal - RETURN: Status: 0xc000007b 1a74:1a0c @ 587204957 - LdrLoadDll - RETURN: Status: 0xc000007b

gurnec commented 7 years ago

Thanks.

Could you please run this from a command prompt and post the results?

powershell -command "Get-FileHash C:\Python27\python.exe,C:\Windows\System32\python27.dll,C:\Windows\SysWOW64\python27.dll,C:\Python27\lib\site-packages\numpy\core\multiarray.pyd | fl"
tigbitties commented 7 years ago

C:\Users\Owner>powershell -command "Get-FileHash C:\Python27\python.exe,C:\Windows\System32\python27.dll,C:\Windows\SysWOW64\python27.dll,C:\Python27\lib\site-packages\numpy\core\multiarray.pyd | fl" Resolve-Path : Cannot find path 'C:\Windows\SysWOW64\python27.dll' because it does not exist. At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Util ity\Microsoft.PowerShell.Utility.psm1:110 char:36

  • $pathsToProcess += Resolve-Path $Path | Foreach-Objec ...
  • CategoryInfo : ObjectNotFound: (C:\Windows\SysWOW64\python27.dl l:String) [Resolve-Path], ItemNotFoundException
  • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Resol vePathCommand

Algorithm : SHA256 Hash : 0DB56AC7BA5F232F5F813109185A3BC885D8D428FEB20997D497F586652477F2 Path : C:\Python27\python.exe

Algorithm : SHA256 Hash : AEA2FC9B989C791F62AF1165B1C866BB65690DEFE6F62A097AC1B08E26469FC7 Path : C:\Windows\System32\python27.dll

Algorithm : SHA256 Hash : FC47FE523F3805B5757701700D24F45B4A32A2DABE2737C62889389454C41035 Path : C:\Python27\lib\site-packages\numpy\core\multiarray.pyd

gurnec commented 7 years ago

Thanks. You definitely have the 64-bit version of Python installed, but the 32-bit version of numpy installed (numpy is installed when you install PyOpenCL). I have no idea why since you've reinstalled everything from scratch.

What's the actual output when you try to reinstall PyOpenCL?

cd Downloads
C:\Python27\Scripts\pip install --upgrade --force-reinstall pyopencl-2017.1.1+cl12-cp27-cp27m-win_amd64.whl

Note: don't download the newest version of PyOpenCL, use the 2017.1.1 version you already have. The newest version (2017.2) has a new problem...

And could you run this once more afterwards?

C:\Python27\python -c "import numpy; print numpy.__version__"
tigbitties commented 7 years ago

I'm out the door. I'll get back to you tomorrow. Thanks so much!!

tigbitties commented 7 years ago

Requirement 'pyopencl-2017.1.1+cl12-cp27-cp27m-win_amd64.whl' looks like a filename, but the file does not exist Processing c:\users\owner\downloads\pyopencl-2017.1.1+cl12-cp27-cp27m-win_amd64.whl Exception: Traceback (most recent call last): File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\python27\lib\site-packages\pip\commands\install.py", line 324, in run requirement_set.prepare_files(finder) File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "c:\python27\lib\site-packages\pip\download.py", line 809, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "c:\python27\lib\site-packages\pip\download.py", line 715, in unpack_file_url unpack_file(from_path, location, content_type, link) File "c:\python27\lib\site-packages\pip\utils__init__.py", line 599, in unpack_file flatten=not filename.endswith('.whl') File "c:\python27\lib\site-packages\pip\utils__init__.py", line 482, in unzip_file zipfp = open(filename, 'rb') IOError: [Errno 2] No such file or directory: 'C:\Users\Owner\Downloads\pyopencl-2017.1.1+cl12-cp27-cp27m-win_amd64.whl'

It looks like I have the newest version of PyOpenCL. I only have the 2017.2 in my download file.

gurnec commented 7 years ago

Could you try to reinstall whichever pyopencl...whl file you do have?

tigbitties commented 7 years ago

Successfully installed appdirs-1.4.3 cffi-1.10.0 colorama-0.3.9 decorator-4.0.11 numpy-1.13.1 py-1.4.34 pycparser-2.18 pyopencl-2017.2+cl12 pytest-3.1.3 pytools-2017.3 setuptools-36.2.0 six-1.10.0

gurnec commented 7 years ago

I was interested in seeing the full output if you don't mind....

tigbitties commented 7 years ago

C:\Users\Owner\Downloads>C:\Python27\Scripts\pip install --upgrade --force-reinstall pyopencl-2017.2+cl12-cp27-cp27m-win_amd64.whl Processing c:\users\owner\downloads\pyopencl-2017.2+cl12-cp27-cp27m-win_amd64.whl Collecting pytest>=2 (from pyopencl==2017.2+cl12) Using cached pytest-3.1.3-py2.py3-none-any.whl Collecting cffi>=1.1.0 (from pyopencl==2017.2+cl12) Using cached cffi-1.10.0-cp27-cp27m-win_amd64.whl Collecting pytools>=2017.2 (from pyopencl==2017.2+cl12) Using cached pytools-2017.3.tar.gz Collecting decorator>=3.2.0 (from pyopencl==2017.2+cl12) Using cached decorator-4.0.11-py2.py3-none-any.whl Collecting appdirs>=1.4.0 (from pyopencl==2017.2+cl12) Using cached appdirs-1.4.3-py2.py3-none-any.whl Collecting six>=1.9.0 (from pyopencl==2017.2+cl12) Using cached six-1.10.0-py2.py3-none-any.whl Collecting numpy (from pyopencl==2017.2+cl12) Using cached numpy-1.13.1-cp27-none-win_amd64.whl Collecting colorama; sys_platform == "win32" (from pytest>=2->pyopencl==2017.2+cl12) Using cached colorama-0.3.9-py2.py3-none-any.whl Collecting setuptools (from pytest>=2->pyopencl==2017.2+cl12) Using cached setuptools-36.2.0-py2.py3-none-any.whl Collecting py>=1.4.33 (from pytest>=2->pyopencl==2017.2+cl12) Using cached py-1.4.34-py2.py3-none-any.whl Collecting pycparser (from cffi>=1.1.0->pyopencl==2017.2+cl12) Using cached pycparser-2.18.tar.gz Installing collected packages: colorama, setuptools, py, pytest, pycparser, cffi, decorator, appdirs, six, numpy, pytools, pyopencl Found existing installation: colorama 0.3.9 Uninstalling colorama-0.3.9: Successfully uninstalled colorama-0.3.9 Found existing installation: setuptools 36.2.0 Uninstalling setuptools-36.2.0: Successfully uninstalled setuptools-36.2.0 Found existing installation: py 1.4.34 Uninstalling py-1.4.34: Successfully uninstalled py-1.4.34 Found existing installation: pytest 3.1.3 Uninstalling pytest-3.1.3: Successfully uninstalled pytest-3.1.3 Found existing installation: pycparser 2.18 Uninstalling pycparser-2.18: Successfully uninstalled pycparser-2.18 Running setup.py install for pycparser ... done Found existing installation: cffi 1.10.0 Uninstalling cffi-1.10.0: Successfully uninstalled cffi-1.10.0 Found existing installation: decorator 4.0.11 Uninstalling decorator-4.0.11: Successfully uninstalled decorator-4.0.11 Found existing installation: appdirs 1.4.3 Uninstalling appdirs-1.4.3: Successfully uninstalled appdirs-1.4.3 Found existing installation: six 1.10.0 Uninstalling six-1.10.0: Successfully uninstalled six-1.10.0 Found existing installation: numpy 1.13.1 Uninstalling numpy-1.13.1: Successfully uninstalled numpy-1.13.1 Found existing installation: pytools 2017.3 Uninstalling pytools-2017.3: Successfully uninstalled pytools-2017.3 Running setup.py install for pytools ... done Found existing installation: pyopencl 2017.2+cl12 Uninstalling pyopencl-2017.2+cl12: Successfully uninstalled pyopencl-2017.2+cl12 Successfully installed appdirs-1.4.3 cffi-1.10.0 colorama-0.3.9 decorator-4.0.11 numpy-1.13.1 py-1.4.34 pycparser-2.18 pyopencl-2017.2+cl12 pytest-3.1.3 pytools-2017.3 setuptools-36.2.0 six-1.10.0

Sorry about that!

gurnec commented 7 years ago

Sorry about that!

No worries! Although everything looks completely normal. Is it still giving the same error message?

C:\Python27\python -c "import numpy; print numpy.__version__"
tigbitties commented 7 years ago

C:\Users\Owner>C:\Python27\python -c "import numpy; print numpy.version" 1.13.1

gurnec commented 7 years ago

So it looks this issue is probably fixed.

Run the GPU unit tests:

C:\Python27\python -m btcrecover.test.test_passwords GPUTests

If you get this notice:

warning: No module named compyte.array

See here to apply a fix for this version of the PyOpenCL downloads.

If it works correctly, you should see this:

OK (skipped=7)

As long as skipped is 7 or less, everything should be all set.

tigbitties commented 7 years ago

I got neither

C:\Python27\python.exe: No module named btcrecover.test

gurnec commented 7 years ago

Oops, sorry, you need to cd into the btcrecover-master folder first.

tigbitties commented 7 years ago

like this? sorry, I'm new at this... and working remotely on my phone

cd btcrecover-master C:\Python27\python -m btcrecover.test.test_passwords GPUTests

gurnec commented 7 years ago

I can't be sure, but it's probably this on your PC:

c:\users\owner\downloads\btcrecover-master
C:\Python27\python -m btcrecover.test.test_passwords GPUTests
tigbitties commented 7 years ago

C:\Users\Owner>c:\users\owner\downloads\btcrecover-master 'c:\users\owner\downloads\btcrecover-master' is not recognized as an internal or external command, operable program or batch file.

C:\Users\Owner>C:\Python27\python -m btcrecover.test.test_passwords GPUTests

tigbitties commented 7 years ago

btcrecover-master is on my desktop... i think thats the problem

gurnec commented 7 years ago

OK, and also I somehow skipped the cd part, oops.

cd c:\users\owner\Desktop\btcrecover-master
C:\Python27\python -m btcrecover.test.test_passwords GPUTests
tigbitties commented 7 years ago

OK (skipped=8)

tigbitties commented 7 years ago

C:\Users\Owner>cd c:\users\owner\Desktop\btcrecover-master

c:\Users\Owner\Desktop\btcrecover-master>C:\Python27\python -m btcrecover.test.test_passwords GPUTests -c: warning: DLL load failed: The specified module could not be found. ssssssss

Ran 8 tests in 0.001s

OK (skipped=8)

c:\Users\Owner\Desktop\btcrecover-master>

gurnec commented 7 years ago

AARRGGHHH! :angry: (That's not directed at you at all!)

Could you try this please?

C:\Python27\python -c "import pyopencl; print pyopencl.version.VERSION_TEXT"
tigbitties commented 7 years ago

c:\Users\Owner\Desktop\btcrecover-master>C:\Python27\python -c "import pyopencl; print pyopencl.version.VERSION_TEXT" Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\pyopencl__init__.py", line 37, in import pyopencl.cffi_cl as _cl File "C:\Python27\lib\site-packages\pyopencl\cffi_cl.py", line 39, in from pyopencl._cffi import ffi as _ffi ImportError: DLL load failed: The specified module could not be found.

c:\Users\Owner\Desktop\btcrecover-master>

if you need a break we can get back to it another day

gurnec commented 7 years ago

if you need a break we can get back to it another day

Nah I'm good. Just need to yell that once. :smile:

Do you have this file on your system? C:\WINDOWS\SYSTEM32\OpenCL.dll

From the command line, you can:

dir C:\WINDOWS\SYSTEM32\OpenCL.dll
tigbitties commented 7 years ago

Nope.

gurnec commented 7 years ago

What GPU (video card) do you have?

tigbitties commented 7 years ago

NVIDIA GeForce GTX 780M

gurnec commented 7 years ago

Could you grab the latest Video drivers from NVIDIA here?

Then check for that file again, and if it's there rerun these two again:

C:\Python27\python -c "import pyopencl; print pyopencl.version.VERSION_TEXT"
C:\Python27\python -m btcrecover.test.test_passwords GPUTests
tigbitties commented 7 years ago

installing...bbl

thanks again

tigbitties commented 7 years ago

Failed to install... I'll get back to you

On Jul 14, 2017 3:53 PM, "Christopher Gurnee" notifications@github.com wrote:

Could you grab the latest Video drivers from NVIDIA here http://www.nvidia.com/download/driverResults.aspx/120489/en-us?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gurnec/btcrecover/issues/79#issuecomment-315452209, or mute the thread https://github.com/notifications/unsubscribe-auth/AcNaAU2FNzSCswEtdOxtKg1Tx3Kx72k3ks5sN8dRgaJpZM4OHBs2 .

tigbitties commented 7 years ago

C:\Users\Owner>dir C:\WINDOWS\SYSTEM32\OpenCL.dll Volume in drive C is OS Volume Serial Number is 82A5-4D9B

Directory of C:\WINDOWS\SYSTEM32

2017-06-27 06:39 PM 512,960 OpenCL.dll 1 File(s) 512,960 bytes 0 Dir(s) 52,099,887,104 bytes free


C:\Users\Owner>C:\Python27\python -c "import pyopencl; print pyopencl.version.VERSION_TEXT" Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\pyopencl__init__.py", line 37, in import pyopencl.cffi_cl as _cl File "C:\Python27\lib\site-packages\pyopencl\cffi_cl.py", line 40, in from .compyte.array import f_contiguous_strides, c_contiguous_strides ImportError: No module named compyte.array

C:\Users\Owner>C:\Python27\python -m btcrecover.test.test_passwords GPUTests C:\Python27\python.exe: No module named btcrecover.test

gurnec commented 7 years ago

ImportError: No module named compyte.array

That's actually much better...

So the version of PyOpenCL you download a week ago has a bug. It was only available for download for a few days, but you must have been unlucky enough to have downloaded it then. To fix:

  1. Delete pyopencl-2017.2+cl12-cp27-cp27m-win_amd64.whl from your downloads directory. This is important - if you don't do this, then the new one you download will have the wrong filename, and the filename matters.
  2. Go back to the download page, and download pyopencl‑2017.2+cl12‑cp27‑cp27m‑win_amd64.whl again.
  3. Open a fresh command prompt, and:
    cd Downloads
    C:\Python27\Scripts\pip install --no-deps --upgrade pyopencl-2017.2+cl12-cp27-cp27m-win_amd64.whl

    Then in the same command prompt, try to run the tests once more.

    cd ..\Desktop\btcrecover-master
    C:\Python27\python -m btcrecover.test.test_passwords -v GPUTests

    At least one test should succeed, up to 7 can be skipped.

tigbitties commented 7 years ago

Processing c:\users\owner\downloads\pyopencl-2017.2+cl12-cp27-cp27m-win_amd64.whl Installing collected packages: pyopencl Found existing installation: pyopencl 2017.2+cl12 Uninstalling pyopencl-2017.2+cl12: Successfully uninstalled pyopencl-2017.2+cl12 Successfully installed pyopencl-2017.2+cl12

C:\Users\Owner\Downloads>cd ..\Desktop\btcrecover-master

C:\Users\Owner\Desktop\btcrecover-master>C:\Python27\python -m btcrecover.test.test_passwords -v GPUTests -c: warning: No module named compyte.array test_bitcoincore_cl (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_bitcoincore_cl_unicode (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_bitcoincore_cl_no_interrupts (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_bitcoincore_cl_sli (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_armory_cl (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_armory_cl_mem_factor (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_armory_cl_no_interrupts (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device' test_armory_cl_sli (main.Test08KeyDecryption) ... skipped u'requires OpenCL and a compatible device'


Ran 8 tests in 0.000s

OK (skipped=8)

gurnec commented 7 years ago

Maybe you browser's cache is getting in the way? Search online for how to clear your browser's cache (and follow the instructions), then go back to that last post and follow all of the steps again (don't skip the first two steps!).

Sorry, but that's the only idea I have...