I'm getting the following error when trying to import models into my google app engine app:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/app/0-1.405524594589080344/main.py", line 6, in <module>
from BaseHandler import BaseHandler
File "/base/data/home/apps/app/0-1.405524594589080344/BaseHandler.py", line 26, in <module>
from user.database import u_db
File "/base/data/home/apps/app/0-1.405524594589080344/user/database/u_db.py", line 12, in <module>
from clubs.database import fed_db, league_db, club_db
File "/base/data/home/apps/app/0-1.405524594589080344/clubs/database/fed_db.py", line 6, in <module>
from events.database import e_db
File "/base/data/home/apps/app/0-1.405524594589080344/events/database/e_db.py", line 7, in <module>
from user.database import u_db
ImportError: cannot import name u_db
I renamed the model files and their container folders, and can see this has something to do with Path.
I would really appreciate some help in fixing this as I am stuck.
Thanks.
You have a circular dependency in your models, see these snippets in your traceback:
File "/base/data/home/apps/app/0-1.405524594589080344/BaseHandler.py", line 26, in <module>
from user.database import u_db
...
File "/base/data/home/apps/app/0-1.405524594589080344/events/database/e_db.py", line 7, in <module>
from user.database import u_db
You need to fix that. Often it can be done simply by moving the import statements inside the functions where they are actually needed instead of just at the top of the file. But not always.
Related
I just tried to use py5 in thonny, but everytime i have the py5 mode on and try to run a code i get a bunch of error messeges, i dont really know what they mean so maybe somebody can help me out ?
thanks in advance
This is the error im always getting
Traceback (most recent call last):
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 52, in <module>
main()
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 44, in main
imported.run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 135, in run_code
_run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 259, in _run_code
_run_sketch(sketch_path, classpath, exit_if_error)
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 196, in _run_sketch
import py5
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5\__init__.py", line 84, in <module>
from py5_tools.magics import load_ipython_extension # noqa
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\__init__.py", line 22, in <module>
from .drawing import DrawingMagics, DXFDrawingMagic
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\drawing.py", line 27, in <module>
from IPython.display import display, SVG, Image
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\__init__.py", line 51, in <module>
from .core.application import Application
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\application.py", line 26, in <module>
from IPython.core import release, crashhandler
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\ultratb.py", line 101, in <module>
import stack_data
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\__init__.py", line 1, in <module>
from .core import Source, FrameInfo, markers_from_ranges, Options, LINE_GAP, Line, Variable, RangeInLine, \
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\core.py", line 19, in <module>
from stack_data.utils import (
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\utils.py", line 11, in <module>
from asttokens import ASTText
ImportError: cannot import name 'ASTText' from 'asttokens' (C:\Users\schwe\AppData\Local\Programs\Thonny\lib\site-packages\asttokens\__init__.py)
I received a response from the py5 developer via Github. They also provided an explanation but it goes over my head, something about "The Python library asttokens is used for parsing syntax trees and syntax highlighting. It is not used by py5 but it might be used by Jupyter Notebook and/or JupyterLab.". They also provided a solution here:
enter link description here
I'm new with Python and NLTK
When I test the following lines in the Python console
import nltk.data
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
text ="toto. titi. tutu"
tokens = tokenizer.tokenize(text)
print(tokens)
I get what I expect. But when I execute these lines from a file, for example with the command line > python tokenize.py, I get errors:
C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\python.exe C:/Documents/Dvpt/SemanticAndOpenData/scholar/scholar.py/tokenize.py
Traceback (most recent call last):
File "C:/Documents/Dvpt/SemanticAndOpenData/scholar/scholar.py/tokenize.py", line 1, in <module>
import nltk.data
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\__init__.py", line 89, in <module>
from nltk.internals import config_java
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\internals.py", line 11, in <module>
import subprocess
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\subprocess.py", line 395, in <module>
import threading
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\threading.py", line 10, in <module>
from traceback import format_exc as _format_exc
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\traceback.py", line 3, in <module>
import linecache
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\linecache.py", line 10, in <module>
import tokenize
File "C:\Documents\Dvpt\SemanticAndOpenData\scholar\scholar.py\tokenize.py", line 2, in <module>
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\data.py", line 786, in load
resource_val = pickle.load(opened_resource)
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\tokenize\__init__.py", line 63, in <module>
from nltk.tokenize.simple import (SpaceTokenizer, TabTokenizer, LineTokenizer,
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\tokenize\simple.py", line 38, in <module>
from nltk.tokenize.api import TokenizerI, StringTokenizer
File "C:\outils\Python\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\nltk\tokenize\api.py", line 13, in <module>
from nltk.internals import overridden
ImportError: cannot import name 'overridden'
Process finished with exit code 1
And I'm stuck on the problem and I can't find a way to solve it. Thanks in advance for any useful proposal.
You need to name the script something other than tokenize.py
The problem here is that you have named your script as tokenize.py. Try renaming the file to something like my_tokenizer.py. Actually what is happening is that when you are using
import tokenize
What it is doing is trying to import the current file itself and thus you are getting the errors.
I'm sure I've done something stupid and the answer is simple, but I can't find it... I want to use pygal on GAE, so I have copied the whole pygal directory to my lib directory. Then, I import it (from another file in lib):
import pygal
Now I get:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "main.py", line 18, in <module>
from lib import output_lib
File "lib\output_lib.py", line 14, in <module>
import pygal
File "lib\pygal\__init__.py", line 34, in <module>
from pygal.graph.bar import Bar
ImportError: No module named pygal.graph.bar
I can fix this by changing
from pygal.graph.bar import Bar
in pygal/__init__.py to
from graph.bar import Bar
but this leads to the next iteration of the error:
...
File "lib\pygal\__init__.py", line 34, in <module>
from graph.bar import Bar
File "lib\pygal\graph\bar.py", line 27, in <module>
from pygal.graph.graph import Graph
ImportError: No module named pygal.graph.graph
So - what's the problem here?
For want of a better solution, I replaced all occurrences of from pygal.* to from lib.pygal.* in all files' import statements. It works, though I still think there must be another way...
I'm trying to load the package enthought.mayavi.mlab in python's spider enviorment:
import enthought.mayavi.mlab as mlb
And I get the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 487, in runfile
execfile(filename, namespace)
File "C:\Users\Eytan\Desktop\Mah\PyBrainTraining.py", line 2, in <module>
import enthought.mayavi.mlab as mlb
File "C:\Python27\lib\site-packages\enthought\mayavi\mlab.py", line 3, in <module>
from mayavi.mlab import *
File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 25, in <module>
from engine_manager import get_engine
File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
from preference_manager import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "C:\Python27\lib\site-packages\traitsui\api.py", line 35, in <module>
from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\__init__.py", line 22, in <module>
from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\api.py", line 10, in <module>
from .code_editor import CodeEditor
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 36, in <module>
class ToolkitEditorFactory ( EditorFactory ):
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 48, in ToolkitEditorFactory
mark_color = Color( 0xECE9D8 )
File "C:\Python27\lib\site-packages\traits\traits.py", line 487, in __call__
return self.maker_function( *args, **metadata )
File "C:\Python27\lib\site-packages\traits\traits.py", line 1183, in Color
return ColorTrait( *args, **metadata )
File "C:\Python27\lib\site-packages\traitsui\toolkit_traits.py", line 7, in ColorTrait
return toolkit().color_trait( *args, **traits )
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 109, in toolkit
_toolkit = _import_toolkit(ETSConfig.toolkit)
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 51, in _import_toolkit
return __import__( name, globals=globals(), level=1 ).toolkit
File "C:\Python27\lib\site-packages\traitsui\qt4\__init__.py", line 18, in <module>
import pyface.qt
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 35, in <module>
prepare_pyqt4()
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 17, in prepare_pyqt4
sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1
anyone knows how to fix it?
Edit: If it will help, I see think that the problem is explained in the last column:
ValueError: API 'QString' has already been set to version 1
Edit: I tried changing API selection for QString and QVariant objects to Api #1,#2. didn't help.
Tried either to set the "Ignore API change errors" to true, didn't help.
Tried EST_TOOLKIT from 'qt4' to 'wx'.
It might be because spider itself uses the QT library and has already initialized it.
According to this http://pythonhosted.org/spyder/installation.html you could use PySide instead of PyQt4 (but i don't know if that's a configuation option or a fallback).
I'm having trouble removing a resource file in a pyqt document, I'm also using monkeystudio IDE. I madea program with images and all linked to a resource file called "resources.qyc" and now I get the error
Traceback (most recent call last):
File "main.py", line 9, in <module>
from Login import Login
File "J:\Newone\Login.py", line 3, in <module>
import mainwindow
File "J:\Newone\mainwindow.py", line 2, in <module>
import Addcadet
File "J:\Newone\Addcadet.py", line 6, in <module>
( Ui_Addcadet, QDialog ) = uic.loadUiType( 'Addcadet.ui' )
File "C:\Python32\lib\site-packages\PyQt4\uic\__init__.py", line 203, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "<string>", line 179, in <module>
ImportError: No module named resources_rc
You'll first have to compile the resource file using pyrcc4. You'll run something like this from command line:
pyrcc4 ResourceFile.qrc -o ui_ResourceFile.py