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

Getting "ImportError: No module named x86_64" when running simple code #93

Closed
bifunctor opened this issue Apr 21, 2019 · 9 comments
Closed

Comments

@bifunctor
Copy link

I have this simple code:

import peachpy
import peachpy.x86_64

x = peachpy.Argument(peachpy.int64_t)

with peachpy.x86_64.Function("Add4", (x,), peachpy.int64_t) as asm_function:
    peachpy.x86_64.LOAD.ARGUMENT(peachpy.x86_64.rax, x)
    peachpy.x86_64.ADD(peachpy.x86_64.rax, 4)
    peachpy.x86_64.RETURN(peachpy.x86_64.rax)

abi = peachpy.x86_64.abi.detect()
encoded_function = asm_function.finalize(abi).encode()
python_function = encoded_function.load()

# The JIT call
print(python_function(-100))

When I run this code, I get this error:

Traceback (most recent call last):
  File "C:/Users/Oround/Desktop/Tests.py", line 2, in <module>
    import peachpy.x86_64
ImportError: No module named x86_64

Why am I getting this error? Is there something I could do to fix it?

@Maratyszcza
Copy link
Owner

Try to reinstall PeachPy following the README

@bifunctor
Copy link
Author

@Maratyszcza Thanks-- but sadly it din't work. I don't get the import error after that, but I get a different error:

TypeError: None is not an ABI object

@Maratyszcza
Copy link
Owner

What does peachpy.x86_64.abi.detect() return?

@bifunctor
Copy link
Author

@Maratyszcza -- When I print it, I get None.

@bifunctor
Copy link
Author

If it helps, I use windows 7.

@bifunctor
Copy link
Author

@Maratyszcza -- This might be a little off topic, but is there a documentation? I tried looking for one, but couldn't find it.

@Maratyszcza
Copy link
Owner

Probably you're using 32-bit Python? The snippet you try to run loads a PeachPy function into the Python process, and its not possible to load 64-bit (x86-64) function into a 32-bit process on Windows.

@bifunctor
Copy link
Author

@Maratyszcza -- I checked my IDLE, and found that you are right; Its 64-bit! Is there some way I could successfully run peachpy using the 32-bit version instead of switching to the 64-bit version?

@Maratyszcza
Copy link
Owner

Maratyszcza commented Apr 24, 2019

You can use PeachPy in 32-bit Python (e.g. to generate an object file that you'd later link into an .exe), but if you want to load PeachPy function as a Python function (like you do in your code), there is no way around using 64-bit Python. This is because you can't execute code for a different architecture (x86-64) from a x86 process.

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

No branches or pull requests

2 participants