Migration fails if pycrypto is unistalled when upgrading from v2.2-beta2 to v2.2.1 #1313

Closed
opened 2025-12-29 16:31:22 +01:00 by adam · 1 comment
Owner

Originally created by @afics on GitHub (Oct 16, 2017).

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation

Environment

  • Python version: 3.4.2
  • NetBox version: 2.2.1

Description

How to reproduce

Upgrading from v2.2-beta2 to v2.2.1.

Running the upgrade script does not remove the pycrypto library.
After verifying whether it is installed by running pip freeze | grep pycrypto, I uninstalled it.

Now when running manage.py migrate, the following error occurs:

Traceback (most recent call last):
  File "./netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/opt/netbox/venv/lib/python3.4/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/netbox/venv/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/opt/netbox/venv/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/opt/netbox/netbox/secrets/models.py", line 4, in <module>
    from Crypto.Cipher import AES, PKCS1_OAEP

Expected behaviour

The migration works fine without pycrypto.

Originally created by @afics on GitHub (Oct 16, 2017). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. If none of the below apply, please raise your issue for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. ---> ### Issue type [ ] Feature request <!-- Requesting the implementation of a new feature --> [x] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) --> ### Environment * Python version: 3.4.2 * NetBox version: 2.2.1 <!-- BUG REPORTS must include: * A list of the steps needed to reproduce the bug * A description of the expected behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description #### How to reproduce Upgrading from ```v2.2-beta2``` to ```v2.2.1```. Running the upgrade script does not remove the ```pycrypto``` library. After verifying whether it is installed by running ```pip freeze | grep pycrypto```, I uninstalled it. Now when running ```manage.py migrate```, the following error occurs: ``` Traceback (most recent call last): File "./netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute django.setup() File "/opt/netbox/venv/lib/python3.4/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/opt/netbox/venv/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models() File "/opt/netbox/venv/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked File "<frozen importlib._bootstrap>", line 1129, in _exec File "<frozen importlib._bootstrap>", line 1471, in exec_module File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed File "/opt/netbox/netbox/secrets/models.py", line 4, in <module> from Crypto.Cipher import AES, PKCS1_OAEP ``` #### Expected behaviour The migration works fine without ```pycrypto```.
adam closed this issue 2025-12-29 16:31:22 +01:00
Author
Owner

@afics commented on GitHub (Oct 16, 2017):

As mentioned in #1578 reinstalling pycryptodome did the trick.

@afics commented on GitHub (Oct 16, 2017): As mentioned in #1578 reinstalling ```pycryptodome``` did the trick.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1313