Can I pickle in python 3 and then crumble in python 2?

The problem I'm trying to solve is this: I have a graph networkxthat I would like to draw as a round tree . This requires Graphvizand PyGraphvizor Pydot, which are not available for Python 3.

I am considering serializing a graph object in python 3 and then de-serializing it in a python 2 environment where I could draw it. However, I do not understand what are the potential problems with this type of approach, since I cannot assume that the corresponding objects are similar in both environments.

Besides the fact that you are trying to do this (I don't currently have a python 2 environment on my machine), is there a way to find out if this is possible? Or does it just make sense to follow a different path, exporting to a different format (for example, gephy), and possibly even making a drawing outside of python?

+4
source share
1 answer

Yes, you can dump data in Python 3 to load it again in Python 2. You might want to install fix_importsas well as use the protocol below 3. From pickle.dump()documenation :

fix_imports , 3, pickle Python 3 , Python 2, pickle Python 2.

2 Python 2.3 - 2.7.

:

+2

Source: https://habr.com/ru/post/1672917/


All Articles