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

v3.6.3 has ImportError on Ubuntu 18.04 #178

Closed
jayschwa opened this issue Jun 29, 2018 · 3 comments
Closed

v3.6.3 has ImportError on Ubuntu 18.04 #178

jayschwa opened this issue Jun 29, 2018 · 3 comments
Labels

Comments

@jayschwa
Copy link

I get ImportError: dynamic module does not define init function (init_cpuid). I do not have a problem with the previous version 3.6.1.

Example:

$ pip install pycryptodomex==3.6.3
$ python -m Cryptodome.SelfTest
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/SelfTest/__main__.py", line 35, in <module>
    SelfTest.run(stream=sys.stdout, verbosity=1, config=config)
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/SelfTest/__init__.py", line 61, in run
    tests = get_tests(config=config)
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/SelfTest/__init__.py", line 82, in get_tests
    from Cryptodome.SelfTest import Cipher; tests += Cipher.get_tests(config=config)
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/SelfTest/Cipher/__init__.py", line 31, in get_tests
    from Cryptodome.SelfTest.Cipher import test_AES;      tests += test_AES.get_tests(config=config)
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/SelfTest/Cipher/test_AES.py", line 29, in <module>
    from Cryptodome.Cipher import AES
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/Cipher/__init__.py", line 36, in <module>
    from Cryptodome.Cipher._mode_gcm import _create_gcm_cipher
  File "/home/jay/.local/lib/python2.7/site-packages/Cryptodome/Cipher/_mode_gcm.py", line 47, in <module>
    from Cryptodome.Util import _cpuid
ImportError: dynamic module does not define init function (init_cpuid)

System info:

$ python --version
Python 2.7.15rc1
$ uname -a
Linux jay-notebook 4.15.0-23-generic #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
@Legrandin
Copy link
Owner

Can you trying explicitly removing version 3.6.1 with pip uninstall pycryptodomex and then do pip install pycryptodomex==3.6.3?

I suspect you have a Cryptodome.Util._cpuid.so hanging around when you install 3.6.3 (and in that version there is a Cryptodome.Util._cpuid.py, which does not get picked up because .so files take precendence).

I guess the new file should have been called differently to avoid this collision...

@Legrandin Legrandin added the bug label Jul 3, 2018
@jayschwa
Copy link
Author

jayschwa commented Jul 3, 2018

Explicitly removing all versions of the module and reinstalling 3.6.3 works. SelfTest passes.

@dejafait
Copy link

dejafait commented Jul 26, 2018

I can confirm in my case that a mysterious leftover file .../python3.4/site-packages/Cryptodome/Util/_cpuid.cpython-34m.so was the cause. I am not sure from which older version of pycryptodomex it came from. Maybe 3.4.6.

pip uninstall pycryptodomex did not help, as can be seen on this output:

Uninstalling pycryptodomex-3.6.3:
  Would remove:
    /.../lib/python3.4/site-packages/Cryptodome/*
    /.../lib/python3.4/site-packages/pycryptodomex-3.6.3.dist-info/*
  Would not remove (might be manually added):
    /.../lib/python3.4/site-packages/Cryptodome/Cipher/_errors.py
    /.../lib/python3.4/site-packages/Cryptodome/Util/_cpuid.cpython-34m.so
    /.../lib/python3.4/site-packages/Cryptodome/Util/_galois.cpython-34m.so
    /.../lib/python3.4/site-packages/Cryptodome/Util/_number_new.py
Proceed (y/n)? y
  Successfully uninstalled pycryptodomex-3.6.3

Pip would never remove the 4 files listed as might be manually added. The mystery still holds: where did they come from?

The solution I chose was to drop and recreate from scratch the whole virtualenv to be sure to get rid of all might be manually added files. This way I would also fix at the same time any other leftover issue from other packages.

This issue costed a lot to my project (broke production because the leftover file was mysteriously absent in preproduction only). Lots of investigation and effort. Hopefully this helps other people.

dejafait added a commit to StartupsPoleEmploi/labonneboite that referenced this issue Jul 26, 2018
this is safe as long as the virtualenv has been fully regenerated
and/or the leftover buggy file python3.4/site-packages/Cryptodome/Util/_cpuid.cpython-34m.so
has been deleted
see Legrandin/pycryptodome#178
dejafait added a commit to StartupsPoleEmploi/labonneboite that referenced this issue Jul 26, 2018
this is safe as long as the virtualenv has been fully regenerated
and/or the leftover buggy file python3.4/site-packages/Cryptodome/Util/_cpuid.cpython-34m.so
has been deleted
see Legrandin/pycryptodome#178
dejafait added a commit to StartupsPoleEmploi/labonneboite that referenced this issue Jul 27, 2018
this is safe as long as the virtualenv has been fully regenerated
and/or the leftover buggy file python3.4/site-packages/Cryptodome/Util/_cpuid.cpython-34m.so
has been deleted
see Legrandin/pycryptodome#178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants