Qpython curses library could not find terminal - curses

I am trying to make a curses script on Qpython, but neither do qpy2 or 3 work.
On Qpython 2, import curses says 'module not found', and on Qpython 3, it works, but at the first initscr it crashes with the following exception:
Traceback (most recent call last):
File "/mnt/sdcard/com.hipipal.qpyplus/scripts3/testcurses.py", line 4, in <module>
win=curses.initscr()
File "/data/data/com.hipipal.qpy3/files/lib/python3.2/python32.zip/curses/__init__.py", line 31, in initscr
_curses.error: setupterm: could not find terminal
I am using the example that came with Qpython 3 as a test.
If that helps, I'm using a kindle fire HD (the old one) with a sideloaded APK from google play.
(no I'm not rooted)

Related

How can I fix my terminal error showing trackback(most recent call)

Whenever I open my terminal Instead of showing the user it shows an error
Traceback (most recent call last):
File "/usr/local/bin/powerline-shell", line 5, in
from powerline_shell import main
ModuleNotFoundError: No module named 'powerline_shell'

How to debug C code with lldb in macOS Mojave?

I was using gdb in Linux but now I have switched to Mac and read that lldb is the alternative to gdb in Apple devices. However, I'm getting an error when I try to use lldb (I also tried gdb but it does not recognize the files as executable). When I try to use it I get the following errors:
sanad#Sanads-MBP  ~/Desktop/cppLab  lldb ./a.out  ✔  623  01:43:54
(lldb) target create "./a.out"
Traceback (most recent call last):
File "", line 1, in
File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 98, in
import six
ImportError: No module named six
Traceback (most recent call last):
File "", line 1, in
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
File "", line 1, in
NameError: name 'run_one_line' is not defined
…and a dozen more NameErrors exactly like this until the output ends with:
Current executable set to './a.out' (x86_64).
(lldb)
lldb links to the System Python.framework, and can only load other python modules if they were built along with that Python library. Turns out, the way Python works if you don't explicitly tell it where to find Python modules it will look alongside the "python" binary that it finds in your PATH. So if you've installed another python and have it in your PATH, then lldb's python will try to load Python modules that won't actually load properly. The current workaround is just to clear you hand-installed Python from your PATH environment variable in whatever Terminal window you want to run lldb from
This was recently fixed (r356819 on llvm.org) and will make it into the Xcode release in the near future.

Create .app / .dmg with Esky

I'm developing a GUI app in Python. I use cx_Freeze to turn my app into .app/ / .dmg files for OS X users. So, for instance I can use python setup.py bdist_dmg to make cx_Freeze create a .dmg file that my users can use to install my app.
I now want my app to update itself automatically. Esky seems to be a promising framework for doing this. I can do python setup.py bdist_esky to create a version of my app that updates itself. It produces the following directory structure:
myapp
myapp-0.1/
myapp
...
...
The top-level myapp is Esky's bootstrapping executable. It looks in the current directory, finds myapp-0.1/ as the latest version and then launches myapp-0.1/myapp.
How do I package this into a .dmg file which I can ship to my users? After my modifications to setup.py to get bdist_esky to work, bdist_dmg no longer works. The impression I get is that Esky is simply not meant to be used with bdist_dmg. Its documentation doesn't mention DMG files at all and I also couldn't find anything on Google.
As a first step, I tried to manually turn the files generated by Esky into an OS X .app/ bundle:
myapp.app/
Contents/
Info.plist
MacOS/
myapp
myapp-0.1/
myapp
...
...
Info.plist contains the minimum amount of necessary information to get OS X to run myapp. When I try to run myapp.app however, I get:
Traceback (most recent call last):
File "<string>", line 318, in bootstrap
File "<string>", line 442, in get_best_version
FileNotFoundError: [Errno 2] No such file or directory: '/Users/michael/Temp/myapp.app/appdata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 689, in <module>
File "<string>", line 335, in bootstrap
RuntimeError: no usable frozen versions were found
Looking at Esky's source code, it appears to have some special handling for OS X bundles in its appdir_from_executable(...) function. To make Esky happy, I tried to rearrange my files so appdata/ actually exists:
myapp.app/
appdata/
myapp-0.1/
myapp
...
Contents/
Info.plist
MacOS/
myapp
...
Unfortunately, this results in another error:
Traceback (most recent call last):
File "<string>", line 689, in <module>
File "<string>", line 336, in bootstrap
File "<string>", line 363, in chainload
File "<string>", line 425, in _chainload
UnboundLocalError: local variable 'exc_value' referenced before assignment
Is this really that difficult? Am I the only one who wants to use Esky and ship files to users in the (standard) .dmg format? What am I missing?
Michael, I saw your comment in the github issue as well. Let me answer it here.
I had the same requirement and resolved in a similar way but I think I didn't use cx_Freeze. Another difference could be that I used Python 2.7.x. The best way to help you is to show you a few relevant files which worked well for me for creating .app and .dmg.
1) The main setup file of the python project:
https://dl.dropboxusercontent.com/u/13110611/temp/package_esky/setup_esky.py
2) The utility script I used to prepare some data files etc
https://dl.dropboxusercontent.com/u/13110611/temp/package_esky/prepare_setup.py
3) The main shell script I used to create app and DMG. That is, this script will call everything else, and it's the only script I used from command line directly.
https://dl.dropboxusercontent.com/u/13110611/temp/package_esky/package.sh
4) The dmg-setup script which will create DMS from .app file. It's just a simple wrapper script to call create-dmg, an open souce project.
https://dl.dropboxusercontent.com/u/13110611/temp/package_esky/dmg-setup
Please try and let me know in case you have any other questions or issues.

Setting up OCR tool in python

I am a complete code novice. I am trying to teach myself python and so far I've been able to do rudimentary scripting. I want to try and learn how to use an OCR which might be somewhat advanced for me, but I'm doing it for fun so I have all the time in the world.
I'm trying to set up pytesser and I understand I need to download both the pytesser module and a PIL. I think there is a problem with how I'm storing my files.
Right now my PIL directory is located in:
C:\Python27\Lib\site-packages
and my pytesser_v0.01 directory is located in:C:\Python27\Lib\site-packages
I try to do the basic test found here
And I keep getting the following error
>>> from pytesser import*
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pytesser
I think this is a very simple question because I keep looking to where to install my PIL and pytesser directories and every online forum/help starts by saying "install it" and not where.
Edit:
I found the correct place to install pytesser but now i'm getting the following errors. The first problem was solved by making sure that pytesser, util, errors and tesseract.exe were in the site-package file and the program didn't have to go into the pytesser folder.
>>> image = Image.open('fnord.tif')
>>> print image_to_string(image)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pytesser.py", line 30, in image_to_string
util.image_to_scratch(im, scratch_image_name)
File "C:\Python27\lib\site-packages\util.py", line 7, in image_to_scratch
im.save(scratch_image_name, dpi=(200,200))
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1433, in save
fp = __builtin__.open(fp, "wb")
IOError: [Errno 13] Permission denied: 'temp.bmp'

Python won't run due to ImportError: cannot import MAXREPEAT

I am new to python but have been using both IDLE and EricIDE for a few weeks without any major problems.
I was editing a program I had written that called random.randint() function and it wouldn't work.
Previously, this program had been working and I had not changed that call out.
I then loaded another program that uses the same function that had been working and it would not run either.
I tried to load the program in IDLE but IDLE wouldn't load. After trying several reboots and reloads EricIDE wouldn't load either. I noticed a black window popping up and disappearing quickly when I try to launch either IDE from my previously working desktop shortcuts.
Searching for help led me to run python shell from the windows command line by going to C:\python33\ and typing "python" to run python shell, I get:
File "C:\python33\lib\sre_constants.py", line 18, in (module)
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
I am using Windows 8 (new to it as well and still trying to figure it out).
At this point I'm assuming my problem is with my python installation since the python shell won't work. I have uninstalled and reinstalled Python 3.3.1 but the problem persists. I also deleted the .idlerc folder from my Users directory as suggested in another thread that was similar to my problem but that doesn't seem to have helped either.
Thank you for any help you can provide.
response to eryksun:
C:\Python33>python.exe -c "import sys; print(sys.path)"
Traceback (most recent call last):
File "C:\Python33\lib\site.py", line 70, in <module>
import re
File "C:\Python33\lib\re.py", line 122, in <module>
import sre_compile
File "C:\Python33\lib\sre_compile.py", line 14, in <module>
import sre_parse
File "C:\Python33\lib\sre_parse.py", line 17, in <module>
from sre_constants import *
File "C:\Python33\lib\sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
C:\Python33>python.exe -S -c "import sys; print(sys.path)"
['', 'C:\\Python33\\python33.zip', 'C:\\Python33\\DLLs',
'C:\\Python33\\lib', 'C:\\Python33']
Follow up to to eryksun:
C:\Python33>python.exe -S -c "import _imp; _sre = _imp.init_builtin('_sre');
print(_sre.MAXREPEAT)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'MAXREPEAT'
I suggest you uninstall. Completely remove C:\Python33 and also C:\Windows\System32\python33.dll. _sre is built in to the latter DLL. MAXREPEAT is set by its initialization functionPyInit__sre (Modules/_sre.c). Clearly, something is wrong there.
When you download the 3.3.1 installer, make sure you get the right binary for your platform, i.e. x86 for 32-bit Windows and X86-64 for 64-bit Windows.

Resources