rsa
rsa

Reputation: 69

Import error: No module named 'Crypto' on Mac (Pycrypto is up-to-date)

Pycrypto has been installed properly (At least to my knowledge. Everything is up to date and I have tried uninstalling and reinstalling with pip). I'm not sure what the issues are here but this code works on others' computers so it has to be something with my configuration specifically. Any help would be greatly appreciated!

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 398, in execute
    self.check()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/checks/urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/checks/urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/Library/Frameworks/Python.framework/Versions/3.4/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 "/Users/samantha/Documents/3rdyrdoe/semester2doe/cs3240-f16-team14/mysite/urls.py", line 25, in <module>
    url(r'^myapplication/', include('myapplication.urls', namespace='myapplication')),
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/Library/Frameworks/Python.framework/Versions/3.4/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 "/Users/samantha/Documents/3rdyrdoe/semester2doe/cs3240-f16-team14/myapplication/urls.py", line 2, in <module>
    from myapplication import views
  File "/Users/samantha/Documents/3rdyrdoe/semester2doe/cs3240-f16-team14/myapplication/views.py", line 9, in <module>
    from Crypto import Random
ImportError: No module named 'Crypto'

Upvotes: 3

Views: 12728

Answers (3)

Z.Xl
Z.Xl

Reputation: 11

I have same problem. I fix it by following command:

pip uninstall pycryptodome
pip uninstall pycrypto
pip uninstall crypto
pip install pycrypto

Upvotes: 1

praveenweb
praveenweb

Reputation: 743

There is a module named "crypto" that is causing the problem. At least for me, in Mac OS. There are two package names "crypto" and "Crypto" which causes this conflict.

Since you are using Python 3.4, try running the following commands to uninstall:

sudo pip3 uninstall crypto
sudo pip3 uninstall pycrypto

Then install the pycrypto module again using:

sudo pip3 install pycrypto

This should solve the issue.

Upvotes: 10

Pythoner
Pythoner

Reputation: 5585

You can use pip list command to check if there is a module named crypto inside your package, if not try easy_install Crypto to install instead of pip.

Upvotes: 0

Related Questions