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

ModuleNotFoundError: No module named '_cffi_backend' #581

Closed
woodpecker02 opened this issue Feb 7, 2020 · 6 comments
Closed

ModuleNotFoundError: No module named '_cffi_backend' #581

woodpecker02 opened this issue Feb 7, 2020 · 6 comments
Assignees

Comments

@woodpecker02
Copy link

woodpecker02 commented Feb 7, 2020

Hello @ALL,

my PIP - Version List:

pip freeze
altgraph==0.17
bcrypt==3.1.7
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
ciscoconfparse==1.4.11
colorama==0.4.3
cryptography==2.8
cx-Freeze==6.1
dnspython==1.16.0
future==0.18.2
idna==2.8
Jinja2==2.11.1
junos-eznc==2.2.1
lxml==4.5.0
macholib==1.14
MarkupSafe==1.1.1
napalm==2.5.0
ncclient==0.6.7
netaddr==0.7.19
netmiko==2.4.2
nxapi-plumbing==0.5.2
paramiko==2.7.1
passlib==1.7.2
pefile==2019.4.18
pycparser==2.19
pyeapi==0.8.3
PyInstaller==3.6
pyIOSXR==0.53
PyNaCl==1.3.0
pyparsing==2.4.6
pyserial==3.4
pywin32-ctypes==0.2.0
PyYAML==5.3
requests==2.22.0
scp==0.13.2
six==1.14.0
textfsm==1.1.0
transitions==0.7.2
urllib3==1.25.8
yamlordereddictloader==0.4.0

python 3.7

when i create my exe-file with cx_Freeze, i got the following Module error:

Traceback (most recent call last):
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts_startup_.py", line 40, in run
module.run()
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 37, in run
exec(code, {'name': 'main'})
File "change_if_description.py", line 10, in
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm_init_.py", line 3, in
from napalm.base import get_network_driver
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm\base_init_.py", line 27, in
from napalm.base.base import NetworkDriver
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm\base\base.py", line 21, in
from netmiko import ConnectHandler, NetMikoTimeoutException
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko_init_.py", line 8, in
from netmiko.ssh_dispatcher import ConnectHandler
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\ssh_dispatcher.py", line 4, in
from netmiko.a10 import A10SSH
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\a10_init_.py", line 2, in
from netmiko.a10.a10_ssh import A10SSH
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\a10\a10_ssh.py", line 4, in
from netmiko.cisco_base_connection import CiscoSSHConnection
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\cisco_base_connection.py", line 3, in
from netmiko.base_connection import BaseConnection
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 22, in
import paramiko
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko_init_.py", line 22, in
from paramiko.transport import SecurityOptions, Transport
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\transport.py", line 89, in
from paramiko.dsskey import DSSKey
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\dsskey.py", line 37, in
from paramiko.pkey import PKey
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\pkey.py", line 31, in
import bcrypt
File "C:\Users\ms\AppData\Local\Programs\Python\Python37\lib\site-packages\bcrypt_init_.py", line 25, in
from . import _bcrypt
ModuleNotFoundError: No module named '_cffi_backend'

When i copy the file "_cffi_backend.cp37-win_amd64.pyd"from my python "site-packages" to my new exe/lib-dir everything works fine.

i hope this will help other!

Regards,
Mario

@marcelotduarte
Copy link
Owner

marcelotduarte commented Feb 7, 2020

You can add the module '_cffi_backend' to the includes list.

from cx_Freeze import setup, Executable

build_options = {"includes": ["_cffi_backend"]}
executables = [Executable("test_crypt.py")]

setup(name='test_crypt',
      version='0.1',
      description='cx_Freeze script to test cryptography',
      executables=executables,
      options={"build_exe": build_options})

@alandmoore
Copy link

alandmoore commented Sep 16, 2021

Hello, I'm still getting this error after adding _cffi_backend to includes. Same happens with the test setup above:

Traceback (most recent call last):
  File "/home/alanm/.local/lib/python3.9/site-packages/cx_Freeze/initscripts/__startup__.py", line 113, in run
    module_init.run(name + "__main__")
  File "/home/alanm/.local/lib/python3.9/site-packages/cx_Freeze/initscripts/Console.py", line 15, in run
    exec(code, module_main.__dict__)
  File "test_crypt.py", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/paramiko/__init__.py", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "/usr/lib/python3.9/site-packages/paramiko/transport.py", line 89, in <module>
    from paramiko.dsskey import DSSKey
  File "/usr/lib/python3.9/site-packages/paramiko/dsskey.py", line 37, in <module>
    from paramiko.pkey import PKey
  File "/usr/lib/python3.9/site-packages/paramiko/pkey.py", line 31, in <module>
    import bcrypt
  File "/usr/lib/python3.9/site-packages/bcrypt/__init__.py", line 25, in <module>
    from . import _bcrypt  # type: ignore
ModuleNotFoundError: No module named '_cffi_backend'

I am using cx-freeze 6.8 from PyPI, Python 3.9 on arch linux 64-bit. I tried my build on Windows 10 and Ubuntu Linux and it succeeded.

@marcelotduarte
Copy link
Owner

The setup above isn't necessary anymore. See this sample: https://github.com/marcelotduarte/cx_Freeze/tree/main/cx_Freeze/samples/bcrypt

@alandmoore
Copy link

With or without the setup, I get the ModuleNotFoundError on arch.

@marcelotduarte
Copy link
Owner

Later I'll try in a docker. What are the versions of the libs used? bcrypt, cffi, etc

@alandmoore
Copy link

bcrypt == 3.2.0
cffi==1.14.6
paramiko == 2.7.2

I think these are the latest versions, which I have installed system-wide from the arch repos. I note that if I pip install these I get older versions from PyPI. Would explain why it works on Ubuntu and Windows, perhaps.

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

No branches or pull requests

3 participants