google / keyczar

Easy-to-use crypto toolkit
Apache License 2.0
1.1k stars 141 forks source link

Errors installing and ImportError while initializing on Python 3 #125

Closed GoogleCodeExporter closed 3 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install the package on Python 3. It will install, but with errors.
2. Attempt to import 'keyczar.keyczar'. This also raises an error.

What is the expected output? What do you see instead?

The package should install nicely and run on Python 3. These errors are seen 
during install:

Running python-keyczar-0.71b\setup.py -q bdist_egg --dist-dir 
c:\users\jaraco\appdata\local\temp\easy_install-moe2i9\python-keyczar-0.71b\egg-
dist-tmp-2lfd9s
  File "build\bdist.win-amd64\egg\keyczar\keyczart.py", line 169
    print "Generating private key sets..."
                                         ^
SyntaxError: invalid syntax

  File "build\bdist.win-amd64\egg\keyczar\util.py", line 800
    except UnicodeDecodeError, exc:
                             ^
SyntaxError: invalid syntax

zip_safe flag not set; analyzing archive contents...
  File "c:\users\jaraco\projects\public\keyring\env\python33\site-packages\python_keyczar-0.71b-py3.3.egg\keyczar\keyczart.py", line 169
    print "Generating private key sets..."
                                         ^
SyntaxError: invalid syntax

  File "c:\users\jaraco\projects\public\keyring\env\python33\site-packages\python_keyczar-0.71b-py3.3.egg\keyczar\util.py", line 800
    except UnicodeDecodeError, exc:
                             ^
SyntaxError: invalid syntax

Adding python-keyczar 0.71b to easy-install.pth file
Installing keyczart-script.py script to 
C:\Users\jaraco\projects\public\keyring\env/Scripts
Installing keyczart.exe script to 
C:\Users\jaraco\projects\public\keyring\env/Scripts

And this is the error occurs during initial import:

>>> import keyczar.keyczar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jaraco\projects\public\keyring\env\Python33\site-packages\python_keyczar-0.71b-py3.3.egg\keyczar\keyczar.py", line 27, in <module>
    import errors
ImportError: No module named 'errors'

What version of the product are you using? On what operating system?

0.71b on Python 3.3 64-bit on Windows 8.

Original issue reported on code.google.com by jaraco@jaraco.com on 7 Feb 2013 at 10:47

GoogleCodeExporter commented 9 years ago
I'm reclassifying this as an enhancement request. While Python 3 support would 
be nice to have and will probably be necessary eventually, the vast majority of 
users will be on Python 2.x for the foreseeable future. In many cases, I 
believe it's not possible for a single codebase to execute with both Python 2.x 
and Python 3, so Python 3 support will likely require creating and maintaining 
a separate Keyczar implementation, and I don't think there's enough value in a 
Python 3 implementation right now to be worth the effort -- at least not unless 
someone is volunteering to step up and be the maintainer for it.

Original comment by swillden@google.com on 7 Feb 2013 at 2:19

GoogleCodeExporter commented 9 years ago
I must politely disagree. Python 3 support must come from the libraries first, 
then from the users. It can't happen the other way around.

It is possible to have a code base run on both Python 2 and Python 3 (see 
CherryPy for an example of a non-trivial library that runs on Python 2.3 
through 3.3 on the same code base).

I'm not saying keyczar needs to run on Python 3, but it surely could attempt to 
support it. If you're willing to provide repo access (or commit to accept some 
pull requests), I can work on some changes to help support Python 3 from the 
same codebase (even if it just invokes 2to3 during install) without creating a 
new maintenance domain.

Supporting Python 3 and Python 2.6+ is much easier than also supporting earlier 
versions of Python (2.5 and earlier). What is the likelihood that keyczar could 
discontinue support for Python 2.5?

Original comment by jaraco@jaraco.com on 7 Feb 2013 at 8:17

GoogleCodeExporter commented 9 years ago
If you're volunteering to do the work, we'd be very happy to accept your 
patches.

The recommended way of contributing to Keyczar is to clone the repository into 
your own Google Code repo, make your changes there, then send a request to the 
mailing list for code reviews. Once the code has passed review, we'll pull it 
into the main rep.

Thanks!

Original comment by swillden@google.com on 7 Feb 2013 at 8:45

GoogleCodeExporter commented 9 years ago
The nice thing is, I've verified that python 2.5 support was broken in 2011, 
don't see any complaints, so i don't think we need to add it back. The bad news 
is, while 2.6-3.X support is easier, it's still a lot of work getting the 
python 3 port working, mainly because of the differentiating of  bytes and 
strings in python3. This will take some time, but i've started some work on it:

https://github.com/jbtule/keyczar-python2to3

Original comment by jtu...@gmail.com on 2 Mar 2013 at 8:46

GoogleCodeExporter commented 9 years ago

Original comment by jtu...@gmail.com on 2 Mar 2013 at 9:07

GoogleCodeExporter commented 9 years ago
okay, so I actually now have all 233 unit tests passing for both Python 2 and 
3, to do this I 

 - moved unit tests to package keyczar.tests
 - moved keyczart to package keyczar.tool
 - Added binary-only api for en/decrypt, attachedverify
 - refactored backend to use streams for all en/decrypt
 - refactored most of the char manipulation to bytes & bytearray
 - removed cut/paste python source code
 - removed circular references

Moving of keyczart to a separate package  is a potential compatibility issue, 
but since python has an api for modifying keysets (unlike java,c++) I don't 
think that's should be an issue.

The new binary api I added, I used the io package BufferedReader and 
BufferedWriter, the public apis I created are `def EncryptIO(self, reader, 
writer)`, `def DecryptIO(self, reader, writer)` and `def AttachedVerifyIO(self, 
signed_data_reader, data_writer, nonce = b"")` If this seems the right way to 
go, this api should be extended to other operations, I implemented these 
specifically as I needed a byte representation only api for 
SignedSessionEncryption in python 3.

Any feedback and help from actual python developers welcome.

Original comment by jtu...@gmail.com on 6 Mar 2013 at 4:42

GoogleCodeExporter commented 9 years ago

Original comment by jtu...@gmail.com on 4 Jul 2013 at 4:24

dylansturg commented 9 years ago

Are there any updates regarding supporting Python 3.0+? I'd like to use Keyczar in a Python 3 project. Thanks for any information.

devinlundberg commented 9 years ago

Unfortunately there are no updates. Jay did a lot of work here https://github.com/jbtule/keyczar-python2to3

Its a gigantic PR that was difficult to break down so we weren't able to finish reviewing it at the time. All of the changes he made make sense from a high level.

@jbtule if you can submit it through a github PR I could start working on the code review.

jbtule commented 9 years ago

added the pull request, #164 it's two years old, don't have time to make a better one.

jamiegau commented 8 years ago

Its nearly december. We are 99% there.. Please roll out into global release.. Python 3 has been around for decades in computer time... And I keep bumping into lack of 2 to 3 upgrades..

With security being an ever more important issues on the internet.. I find the complacency here astounding.

dmyerscough commented 8 years ago

Any updates on when keyczar will be GA for Python 3?

rsyring commented 8 years ago

Python 3 adoption is really taking off. Maybe Priority-Low isn't so true anymore?

nickbaum commented 8 years ago

For what it's worth, Keyczar is the only Python library we use that still isn't compatible with Python 3.

This seems like it would be a great 20% project for someone on the Google Security team :)

jbtule commented 8 years ago

Less than 20% when all is needed is just auditing and merging a 3 year old pull request.

Sent from my iPhone

On Mar 30, 2016, at 12:45 PM, Nick Baum notifications@github.com wrote:

For what it's worth, Keyczar is the only Python library we use that still isn't compatible with Python 3.

This seems like it would be a great 20% project for someone on the Google Security team :)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

nickbaum commented 8 years ago

I suspect a 3 year old pull request would be non-trivial to review, but I'm in no position to judge.

hsdhillon commented 8 years ago

+1 for this request. Any ETA as when Python 3 support will be available??

questin commented 8 years ago

+1 for this request also. Latest Ubuntu LTS ships with Python 3 now as default. This is the last library our platform need to run on 3. Thanks.

soferio commented 8 years ago

+1.

soferio commented 8 years ago

Is this the answer? : https://pypi.python.org/pypi/python3-keyczar/0.71rc0

pembo13 commented 6 years ago

It's 2018... is there a solution to this?

nickbaum commented 6 years ago

@edknapp posted some updates in this issue.

https://github.com/google/keyczar/issues/213

TL;DR is that work is happening but don't expect something soon

dennismwagiru commented 6 years ago

Yes soferio, use https://pypi.python.org/pypi/python3-keyczar/0.71rc0 pip install python3-keyczar

pembo13 commented 6 years ago

@dennismwagiru as of right now python3-keyczar depends on pycrypto, which I can't get to build on Centos7 with Python36. Pycrpto itself is dead.

dennismwagiru commented 6 years ago

@pembo13, first install pycryptodome and the rename the pycrptodome folder to pycrypto before installing python3-keyczar

dennismwagiru commented 6 years ago

@pembo13, this might also be helpful

https://stackoverflow.com/questions/41813030/problems-with-installation-pycrypto-in-python-3-6

frispete commented 6 years ago

@dennismwagiru

first install pycryptodome and the rename the pycrptodome folder to pycrypto

Please note, PyCryptodome is meant as a drop-in replacement of PyCrypto (with absolutely inevitable incompatibilities only). If a rename is necessary, that would be a bug in one of the involved packages.

jonathan-chao-artivest commented 5 years ago

what is the correct import?

from keyczar import keyczar

returns import error still, even for python3-keyzcar

Is it a different import package?