0

I am new to Python (as of today) and having trouble following this example for AES: https://pypi.python.org/pypi/pycrypto/2.6.1 using Python 3.3

from Crypto.Cipher import AES

I downloaded the package from here https://www.dlitz.net/software/pycrypto/ (pycrypto-2.6.1.tar.gz) as I want it as a local dependency since this is a portable plugin for Sublime Text 3.

So I have /MyPLugin/Crypto/ and Crypto looks good having the expected __init__.py files in the right places.

In /MyPlugin/myplugin.py I am trying to import AES like in the example (from Crypto.Cipher import AES). I have tried many combinations with dots and stuff but nothing seems to work.

How can I import AES from this relative Crypto folder?

Couple of the tries:

from MyPlugin.Crypto.Cipher import AES = ImportError: cannot import name AES

import Crypto = ImportError: No module named 'Crypto'

import .Crypto = SyntaxError: invalid syntax

PS I made a mistake - it is using Python 3.3

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Dominic
  • 62,658
  • 20
  • 139
  • 163

1 Answers1

2

Make sure that the library you are talking about is in your python path. Information about modifying your python path here. I'd try doing that. Although, when you add a new library this usually happens.

deweyredman
  • 1,440
  • 1
  • 9
  • 12
  • Thanks, but this is a plugin for Sublime Text 3 so I cannot modify the users system I think, also I made a mistake this is for Python 3.3 I didn't realise sublime 3 bundles it's own version of Python now – Dominic May 07 '14 at 21:27
  • Whenever you install a library, you have to modify the python path or python cannot access what you have installed. You're modifying the python path, not the system path fyi – deweyredman May 07 '14 at 21:29
  • Also, try looking here: http://stackoverflow.com/questions/19799990/sublime-text-plugin-adding-python-libraries – deweyredman May 07 '14 at 21:32