-
Notifications
You must be signed in to change notification settings - Fork 13
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
Error in Questa simulator when importing AES from Crypto.Cipher #19
Comments
Can you try to import I think there is some issue in pysv that not be able to pick up foreign module. I will fix this issue. |
Thanks for the quick reply, updated trial with below coding:
The issue is still there on my side: # do run.do |
It looks like the module is imported correctly, but the submodule is not. Can you copy and paste the generated C++ code here? It should have the python path hardcoded in. You can mask off username etc. |
[libpysv.cc]
One thing I notice is that the Crypto package from my side is being installed in a virtual env (venv) path, which is located at /home//pyvenv/env3/lib/python3.6/site-packages/*, e.g.
Looks like the generated libpysv.cc does not include that venv path. But it includes this path: "/home//.local/lib/python3.6/site-packages", which also includes the Crypto/Cipher/.... |
Just to make sure, you ran pysv inside the venv environment right? The python path is generated from this code: Lines 474 to 485 in 3c8f05b
Does your EDIT:
|
i noticed previously there were some issues in my venv setup, now I have re-setup & re-run it with venv and this is the SYS_PATH:
My sys.path looks like this:
From what I can see it matches The ERROR msg "AttributeError: module 'Crypto' has no attribute 'Cipher'" from questasim still exists with this run. ==================================== full libpysv.cc
|
Hmm, looks like the import logic might not be correct. I can try to reproduce it on my end. What is the pypi package name for that module? I think one workaround is to import the module name only, and then use the full name in your code. Maybe that will work? e.g. import Crypto
# later on inside the function
from Crypto.Cipher import AES |
The pypi module is "pycryptodome" As for the workaround are you suggesting something like this?
I had a quick trial on the above code and it seems the import issue is gone. vsim log:
|
Thanks. I will take a look and fix the import logic.
Yes this is exactly what I have in mind. I'm preparing my defense and dissertation right now so I'm not sure how much bandwidth I have to fix this issue. I will leave this issue open to track it. Thanks for reporting it and providing good examples. |
I saw a similar issue w.r.t "Getting an error in Questa simulator when importing PyCrypto library from Python #16"
The python I used is python 3.6.5 and i have installed pycryptodome.
I am using linux platform and followed the setup, but it seems importing AES from Crypto.Cipher gives me errors when running it with questasim (ver 2020.4):
# do run.do
terminate called after throwing an instance of 'pybind11::error_already_set'
what(): AttributeError: module 'Crypto' has no attribute 'Cipher'
My code looks like below:
[crypto_test.py]
[top1.sv]
[vsim.sh]
[run.do]
run -all
The text was updated successfully, but these errors were encountered: