Importing a resource file - python

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

Related

Python bamboolib has no attribute plugins

I'm trying to install bamboolib on a virtual env (py 3.6.8) but when I try to import the library on Jupyter lab I get the following error: module 'bamboolib' has no attribute 'plugins'.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\__init__.py", line 85, in <module>
from bamboolib.wrangler import show
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\wrangler.py", line 81, in <module>
from bamboolib.views.suggest_string_manipulation import SuggestStringManipulation
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\views\suggest_string_manipulation.py", line 13, in <module>
from bamboolib.transformation_plugins.string_transformations import (
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\transformation_plugins\__init__.py", line 5, in <module>
from bamboolib.transformation_plugins.bulk_change_datatype import BulkChangeDatatype
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\transformation_plugins\bulk_change_datatype.py", line 9, in <module>
from bamboolib.plugins import TransformationPlugin, DF_OLD, DF_NEW, Singleselect, Text
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\plugins\__init__.py", line 6, in <module>
from bamboolib.plugins._utils import create_plugin_base_class
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\plugins\_utils.py", line 5, in <module>
import bamboolib.plugins._registry as PluginRegistry
AttributeError: module 'bamboolib' has no attribute 'plugins'

Thonny py5-mode Error when running a code

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

Model Import error

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.

Using pwntools in mac

I want to use pwntools(which is python module) in my mac. However I get error instead of pwntools. I tried all step in https://github.com/Gallopsled/pwntools/issues. But I get
Traceback (most recent call last):
File "/Users/Knight/PycharmProjects/untitled/gmail.py", line 1, in <module>
import pwn
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwn/__init__.py", line 2, in <module>
from .toplevel import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwn/toplevel.py", line 20, in <module>
import pwnlib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/__init__.py", line 40, in <module>
importlib.import_module('.%s' % module, 'pwnlib')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/args.py", line 10, in <module>
from . import term
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/__init__.py", line 3, in <module>
from . import completer
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/completer.py", line 4, in <module>
from . import readline
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/readline.py", line 4, in <module>
from . import text
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/text.py", line 115, in <module>
sys.modules[__name__] = Module()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/text.py", line 26, in __init__
self.num_colors = termcap.get('colors', default = 8)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/termcap.py", line 25, in get
s = curses.tigetstr(cap)
_curses.error: must call (at least) setupterm() first
I can't understand why I can't use it.
Help me please
You must set the following environment variables as indicated here
export TERM=linux
export TERMINFO=/etc/terminfo
Setupterm could not find terminal, in Python program using curses

How should I solve Attribute and Import errors generated on using py2exe?

I have created an exe file using py2exe, however it gives me an Attribute error and an import error on execution. I have used urllib2 and BeautifulSoup in my main script, which is abc.py
Here is my setup.py:
from distutils.core import setup
import py2exe
setup(console=['abc.py'])
options={"py2exe": {'includes': ["BeautifulSoup"]}}
I have added the 'includes' parameter after referring to another question on this website. It however doesn't work for me.
The output I get from abc.exe is
C:\Users\Dhruv Mullick\Desktop\dist>abc.exe Traceback (most recent
call last): File
"C:\Python27\lib\site-packages\py2exe\boot_common.py", line 92, in
import linecache File "linecache.pyc", line 9, in File "os.pyc", line 398, in File "UserDict.pyc", line 83,
in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in File "bs4__init__.pyc", line 30, in
File "bs4\builder__init__.pyc", line 1, in File
"collections.pyc", line 6, in AttributeError: 'module' object
has no attribute 'all' Traceback (most recent call last): File
"abc.py", line 3, in File "bs4__init__.pyc", line 26, in
File "os.pyc", line 398, in File "UserDict.pyc",
line 83, in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in ImportError: cannot import name
BeautifulSoup
C:\Users\Dhruv Mullick\Desktop\dist>
Your script 'abc.py' conflicts with the abc module in Python's standardlibrary.
Rename the script to something else (maybe abc_app.py), adapt the setup-script and rebuild.
You should also make sure to remove any 'abc.pyc' or 'abc.pyo' files which you may have. And remove the 'build' directory that py2exe creates...

Categories

Resources