TikZ-Editor
TikZ-Editor copied to clipboard
cannot import name 'factory'
I get the following error when trying to execute tikz_editor.pyw
Traceback (most recent call last):
File "./tikz_editor.pyw", line 18, in <module>
import tikz_editor
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/__init__.py", line 20, in <module>
from tikz_editor.controllers import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/__init__.py", line 16, in <module>
from .factory import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/factory.py", line 19, in <module>
from .documents import DocumentsController
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/documents.py", line 17, in <module>
from . import factory
ImportError: cannot import name 'factory'
I get the same error when running setup.py install
I'll check that... maybe it's because I switched the master branch to py3/qt5 ? The py2/qt4 version is maintained in branch https://github.com/fredokun/TikZ-Editor/tree/py2qt4 (corresponding to PR #8). In the meantime I investigate the problem.
Yeah ... I think it's a python2 vs. python3 issue, can you confirm ?
I can confirm. The py2qt4 branch works on my system.
ok, sorry for the sudden (unadvertised) change
@fredokun they py2qt4 branch works with python2
on my system, but the master branch does not work with python3
or python2
. I am confused why you closed the issue.
I tried with python3 qt5 and it worked... I think it's also an issue with qt5 not installed or for python2? I'll reopen if it's something else...
Le 8 nov. 2017 4:33 PM, "Jason Siefken" [email protected] a écrit :
@fredokun https://github.com/fredokun they py2qt4 branch works with python2 on my system, but the master branch does not work with python3 or python2. I am confused why you closed the issue.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fredokun/TikZ-Editor/issues/9#issuecomment-342854241, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDadDYeYvntOhTydp41RHdwSbHyaC1yks5s0cnXgaJpZM4QV01N .
I am able to run the example here: http://zetcode.com/gui/pyqt5/firstprograms/ with both python2
and python3
, which makes me think pyqt5
is installed correctly for both versions of python. Both python2
and python3
have the same error wiht TikZ-Editor
.
albert@turbo ~/programming/latexwatch/TikZ-Editor $ python3 tikz_editor.pyw
Traceback (most recent call last):
File "tikz_editor.pyw", line 18, in <module>
import tikz_editor
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/__init__.py", line 20, in <module>
from tikz_editor.controllers import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/__init__.py", line 16, in <module>
from .factory import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/factory.py", line 19, in <module>
from .documents import DocumentsController
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/documents.py", line 17, in <module>
from . import factory
ImportError: cannot import name 'factory'
albert@turbo ~/programming/latexwatch/TikZ-Editor $ python2 tikz_editor.pyw
Traceback (most recent call last):
File "tikz_editor.pyw", line 18, in <module>
import tikz_editor
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/__init__.py", line 20, in <module>
from tikz_editor.controllers import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/__init__.py", line 16, in <module>
from .factory import ControllerFactory
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/factory.py", line 19, in <module>
from .documents import DocumentsController
File "/home/albert/programming/latexwatch/TikZ-Editor/tikz_editor/controllers/documents.py", line 17, in <module>
from . import factory
ImportError: cannot import name factory
I do not have access to a mac (for now) but I'll investigate this, I reopen the issue.
(I tried on linux and it works)
but it seems you're on a unix box also ?
I am on linux (gentoo). Let me know if there are other tests you'd like me to run.
what is your version of python 3 ?
Python 3.4.5 Python 2.7.12
I also have PyQt5
version 5.7.1
. I have gotten the code to run by doing the following:
- I moved the
from . import factory
from the beginning ofcontrollers/documents.py
to thedef _createDocument
method. I'm not sure when_createDocument
is called, so maybe the issue still exists and just isn't triggered, or maybe this fixed it... - After I did that there was a new problem with the preferences. They were all being returned as strings instead of bools/ints, etc. I manually hacked the 10 calls to preferences that were failing, adding things like
True if value == 'true' else False
. This makes me suspicious that a different version ofPyQt5
automatically converts these types to python types? If so, the laziest fix would be to put a minimum version ofPyQt5
required. Otherwise, it would be reasonable to do type coercion inpreferences.py
.
This appears relevant: http://pyqt.sourceforge.net/Docs/PyQt5/pyqt_qsettings.html
@siefkenj I ported it to Qt5 using the currently latest version: QT 5.9. and python 3.6. But yes, I didn't test it with lower version. Hope that helps.
I made a PR #10 to address the issue.
merged, thanks !