I'm working on a class project (don't worry, this question is not homework) and recently moved from department machines to my own machine.
The project is to build a simple operating system. To make the task easier, we are provided with the ability to "attach" gdb to QEMU in which our program runs. Running this program without attaching gdb on my computer works fine, however it is when I start trying to use gdb that it does not run.
The main thing to note (I think) is that it runs fine on the department computers (gdb 7.4.1-debian) but not on mine (7.6.1-ubuntu).
The error I am getting pertaining to python is that gdb extensions are written in python but they do not seem to be found. I am also getting syntax error. A run of the program looks like this:
/usr/bin/qemu-system-i386
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/alfonso/course/cs167/weenix/kernel/weenix.dbg...done.
After which it hangs for a bit, then gives me this error:
inittmp.gdb:1: Error in sourced command file:
localhost:1234: Connection timed out.
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/mm/memcheck.py", line 5, in <module>
import weenix
ImportError: No module named 'weenix'
File "/home/alfonso/course/cs167/weenix/kernel/mm/page.py", line 15
print "pagesize: {0}".format(weenix.kmem.pagesize())
^
SyntaxError: invalid syntax
File "/home/alfonso/course/cs167/weenix/kernel/mm/slab.py", line 40
print "{1:<{0}} {3:>{2}} {5:>{4}} {7:>{6}}".format(
^
SyntaxError: invalid syntax
File "/home/alfonso/course/cs167/weenix/kernel/proc/proc.py", line 17
print weenix.proc.str_proc_tree()
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/util/debug.py", line 3, in <module>
import weenix
ImportError: No module named 'weenix'
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/util/list.py", line 3, in <module>
import weenix
ImportError: No module named 'weenix'
Breakpoint 1 at 0xc0008f04: file util/debug.c, line 190.
Breakpoint 2 at 0xc0007016: file main/kmain.c, line 298.
Breakpoint 3 at 0xc0006cf3: file main/kmain.c, line 129.
init.gdb:6: Error in sourced command file:
The program is not being run.
Of course, the import errors and invalid syntaxes made me initially think about my PYTHONPATH and/or package settings, but that is something that works fine (tested it). The only thing I can think of is that I have some configuration problems that I am overlooking.
If you would like me to, I can post the bash script, .gdb files and the rest, but since this works fine on department computers, I doubt this is the problem.
Python versions: (department: "2.7.3", me: "2.7.5+")
EDIT:
After some searching, I have realized that the newest Linux Mint(petra) uses gdb that interprets python as python3. I am currently looking for a way to configure gdb, but as I have never done it before, I would appreciate if someone could direct me in doing so.
You use Python 3 for this debug mode.
$ python3 test33.py
File "test33.py", line 1
print "hello".format()
^
SyntaxError: invalid syntax
Make sure you use Python 2 as you say.
I'm doing this homework, too. (I guess weenix is too commonly used for OS courses.)
Regarding "import weenix" problem, it's because weenix's python script isn't in gdb's data directory. When using gdb with python, this dir will be added to python's PATH automatically. Therefore, just put "weenix/python/weenix" under your data directory/python. As for me, it's /usr/shared/gdb/.
Having fun with weenix!
Related
I'm using PyGObject/GTK+ with Python3.7 on Windows and is worried about how to package my app. With official Python ecosystem, it's easy to use freezers and venvs. However, the PyGObject and GTK+ on Windows requires the MingW environment to run.
Does this mean that I have to package the entire MingW, along with GTK+?
How should I freeze the app?
Since no one cares soon enough, I'll report my findings here. The short answer, as of the date I write this post, is: The PyGObject eco-system is not commercial-ready on Windows, although nothing stops you from shipping a functional app.
The deal-breaker is the lack of functional freezers on Windows for PyGOBject. So you can't really ship a closed-source commercial product with it (although one could argue that the entire Python eco-system is not made for that). The freezers that I tried:
The officially recommended PyInstaller right now does not install with the officially recommended msys/MingGW universe; Even after building PyInstaller from source, the frozen .exe crashes with complaints about missing modules. Below is the crash report from a hello-world app.
$ app.exe
[8340] mod is NULL - structTraceback (most recent call last):
File "C:/Apps/msys64/mingw64/lib/python3.7/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
[8340] mod is NULL - pyimod02_archiveTraceback (most recent call last):
File "C:/Apps/msys64/mingw64/lib/python3.7/site-packages/pyinstaller-3.5-py3.7.egg/PyInstaller/loader/pyimod02_archive.py", line 28, in <module>
import struct
ModuleNotFoundError: No module named 'struct'
[8340] mod is NULL - pyimod03_importersTraceback (most recent call last):
File "C:/Apps/msys64/mingw64/lib/python3.7/site-packages/pyinstaller-3.5-py3.7.egg/PyInstaller/loader/pyimod03_importers.py", line 24, in <module>
from pyimod02_archive import ArchiveReadError, ZlibArchiveReader
ModuleNotFoundError: No module named 'pyimod02_archive'
Traceback (most recent call last):
File "site-packages/pyinstaller-3.5-py3.7.egg/PyInstaller/loader/pyiboot01_bootstrap.py", line 15, in <module>
ModuleNotFoundError: No module named 'pyimod03_importers'
[8340] Failed to execute script pyiboot01_bootstrap
cx_Freeze, another prominent alternative, does not build/install on MingW, either. You end up with gcc woes, no matter how many gcc variants you install.
py2exe is now abandonware since Python 3.4.
Since a PyGObject app still runs with MinGW python, it's not impossible to ship such an app for Windows. But that means you'll go with the big baggage and figure out a way to pack everything yourself. Let alone maintain the whole mess. Mind you that the procedure will be different on Mac if your app is cross-platform. PyInstaller works on Mac according to my test.
QuodLibet provides an example of how to ship an open-source software based on PyGObject. Unfortunately, as of today, the upstream's packaging procedure fails at the build.sh run on my Windows 10:
copying data/quodlibet.zsh -> E:\_dev\quodlibet\win_installer\_build_root\mingw64\share\zsh\vendor-completions\_quodlibet
Traceback (most recent call last):
File "E:/_dev/quodlibet/win_installer/misc/depcheck.py", line 141, in <module>
main(sys.argv)
File "E:/_dev/quodlibet/win_installer/misc/depcheck.py", line 130, in main
libs = get_things_to_delete(sys.prefix)
File "E:/_dev/quodlibet/win_installer/misc/depcheck.py", line 108, in get_things_to_delete
for lib in get_dependencies(path):
File "E:/_dev/quodlibet/win_installer/misc/depcheck.py", line 66, in get_dependencies
data = data.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 72: invalid start byte
This turns out to be an easy fix: locale issue on non-UTF8 Windows.
A trivial patch would be replacing "utf-8" with locale.getdefaultlocale(). After that, the build succeeds.
However, the global distribution issues remain challenging:
Bloated pipeline: The officially recommended msys2 build system basically drags the entire GNOME universe and much of the Python universe to your machine, while you may already have a Python environment on your native Windows. It proves hard to cherry-pick the necessary dependencies among this whole pile of stuff.
Extra C pipeline required to build the executable. To build a Windows executable without a freezer, you must create your app as a Python package (big hassle), install it to your msys2-Python site-packages (another setup.py hassle), and then build a wrapper C application using the Python C API (opaque hassle). The process is not transparent, especially when Python packaging system is sensitive to working directory and path differences. Launching the executable can easily go wrong without much debug info.
Manual stripping. As mentioned above, you must manually cherry-pick dependencies or your app would be shipped with basically the entire msys2/MinGW universe that's worth 100MB+ for a hello-world app.
I have seen many threads that have a high level of ambiguity and go off on tangents from the original question, often assuming much about the authors ability, so I am hoping that if I am direct and concise with my information, I will get an answer that is in line with the requirement. I know that the serious programmers will have seen this many times, in many formats, so please just bear with me as this is doing my head in. Please do not just post a link to some other answer as I rarely find that helps with my current issue.
I am not a hardcore programmer, I find the compiling, sourceball, tar, gz all nonsense to be honest and am looking for the easiest way to install sip for python on my machine. I have installed various versions of mingw32, mingw64 to the point that I don't know which one is best to use. I am assuming that the one here: C:\Program Files\mingw-w64 is the one, considering I am using 64 bit, but do the others I have installed impact on this?
I also installed versions of mysys:
C:\msys\1.0,
C:\msys64, but I still m unclear what and why etc, despite trying to read the docs that came with them.
I have windows 10, 64 bit professional edition.
I have python 2.7
I have installs of mingw, 32 bit and 64 bit in various locations, due mostly to not fully understanding what exactly it was or where it should go. I found zips of it and exes, so I got a bit confused.
I downloaded the sip package and unpacked it to here: C:\Python27\Lib\site-packages\sip-4.19.3 and it has the configure.py file in it. So far, so good.
I used a CMD window, changed directory to: C:\Python27\Lib\site-packages\sip-4.19.3 and then used the command: python configure.py to create the Makefile file which is what I believe is supposed to happen.
I then opened the mingw64 shell, changed directory to the above sip folder and typed: python configure.py again, just to be sure I would get a response and create the files again, probably should not have done so, but hey ho, at this point, I am quite frustrated with it and trying to do anything with what I have, which I know is poor practice. (see image 1.)
image 1: configure.py executed
From what I have read, I should use the make function that comes with Mingw64, but I tried the following, which also includes the configure.py code, but nothing seems to work when trying to use the Makefile file that was created via the configure.py process.
c:\Python27>cd ./Lib/site-packages/sip-4.19.3
c:\Python27\Lib\site-packages\sip-4.19.3> python configure.py
This is SIP 4.19.3 for Python 2.7.13 on win32.
The SIP code generator will be installed in C:\Python27.
The sip module will be installed in C:\Python27\Lib\site-packages.
The sip.pyi stub file will be installed in C:\Python27\Lib\site-packages.
The sip.h header file will be installed in C:\Python27\include.
The default directory to install .sip files in is C:\Python27\sip.
Creating siplib\sip.h...
Creating siplib\siplib.c...
Creating siplib\siplib.sbf...
Creating sipconfig.py...
Creating top level Makefile...
Creating sip code generator Makefile...
Creating sip module Makefile...
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3> make Makefile
make: Nothing to be done for `Makefile'.
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3>
So now I am at an impasse. I have the locations of my mingw versions and the msys in my path environment variable and I have done just about everything I have looked at on the web. I realise that its an order of things, but I really wish there were just executables for these modules and supporting tools as this compiling is a ball ache.I tried opening a python shell and importing sip.
>>> import os, sys
>>> import sip
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import sip
ImportError: No module named sip
>>> import sipconfig
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import sipconfig
ImportError: No module named sipconfig
>>> from sip import sip
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from sip import sip
ImportError: No module named sip
>>> from sipconfig impport sip
SyntaxError: invalid syntax
>>> from sip import *
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from sip import *
ImportError: No module named sip
So, if anyone has read through this and has a definitive answer as to what I am doing wrong, I would appreciate it.
make/nmake or make/nmake install cant be done from cmd and python path; instead using mingw or visual studio tools.
In windows search for prompt or Visual studio tools to open VS Command promt and from there cd--> sip file location (before this run configure.py present in sip folder)
Now run the commands nmake and then nmake install
I recently added a tool to my makefile's toolchain that is written in python. It processes .json input and outputs some assembly data, and when in run the python tool from the console (e.g. python xxx.py -o yyy.s zzz.json) it works quite well. However when the same script is run from within the makefile, suddenly package imports fail (concretly spoken those I installed using pip).
The makefile outputs the following error:
Traceback (most recent call last):
File "tools/pyset2s.py", line 2, in <module>
import pymap.tileset
File "/cygdrive/d/Hacking/__Violet_Sources/tools/pymap/tileset.py", line 3, in <module>
from . import image, palette, agbimg
File "/cygdrive/d/Hacking/__Violet_Sources/tools/pymap/image.py", line 3, in <module>
import png
ImportError: No module named png
make: *** [makefile:135: bld/map/tileset/gfx_maptileset0.s] Error 1
make: *** Waiting for unfinished jobs....
The only cause of this problem I figured so far might be, that the package (in this case PyPng, but I suppose it will also fail on the other ones (being Pilow and numpy) was installed while being in administrator mode (I am working under Windows and using a cygwin shell for the make call). However reinstalling the package did not work, since I am told, that the requirements are already satisfied. I also do not know who to promote my IDE (I am using Netbeans) to use adminstrator rights when running the make command.
Is there any solution to that?
i am starting to use Databases and am using MariaDB, Got that ready, but i want Python integration so i can get started on the program.
I have downloaded PyMySQL-0.7.10.tar.gz from the official python website
and have unzipped and have navigated an Command Prompt to there using cd (dir).
My command is:
"G:\Python\Portable\Portable Python 3.2.5.1\App\python.exe" setup.py install
(Yes, i am on Windows 10 and i am using Portable Python. This is because i learn it at school but also want to be able to work at it at home.)
The error it returns is the following:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
version_tuple = __import__('pymysql').VERSION
File "C:\Users\Natan Samuel Geldorp.Remytop-PC\Downloads\PyMySQL-0.7.10\pymysql\__init__.py", line 28, in <module>
from .converters import escape_dict, escape_sequence, escape_string
File "C:\Users\Natan Samuel Geldorp.Remytop-PC\Downloads\PyMySQL-0.7.10\pymysql\converters.py", line 60
_escape_table[0] = u'\\0'
^
SyntaxError: invalid syntax
Does anyone know how to fix this?
-Natan
As requested, as an answer:
You need a newer Python version, in 3.0 to 3.2 the u prefix was forbidden, it was allowed again in version 3.3.
Since Portable Python is no longer being developed (according to their site) you need to pick an alternative. One suggested on the site is WinPython.
(Also the PyMySQL site states that the minimum required Python versions are either >= 2.6 or >= 3.3)
I'm trying to use weave.blitz to speed up some code and I keep getting the following DLL error. If I run a simple code, e.g.
from scipy import * # or from NumPy import *
a = ones((512,512),'Float64')
b = ones((512,512),'Float64')
# now average
a[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1] \
+ b[1:-1,2:] + b[1:-1,:-2]) / 5.
from scipy import weave
expr = "a[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]" \
"+ b[1:-1,2:] + b[1:-1,:-2]) / 5."
weave.blitz(expr)
I get the following error:
Traceback (most recent call last):
File "C:\Users\Thijs\wtest.py", line 19, in <module>
weave.blitz(expr)
File "C:\Python27\lib\site-packages\scipy\weave\blitz_tools.py", line 65, in blitz
**kw)
File "C:\Python27\lib\site-packages\scipy\weave\inline_tools.py", line 488, in compile_function
exec 'import ' + module_name
File "<string>", line 1, in <module>
ImportError: DLL load failed: Invalid access to memory location.
I'm using the latest Pythonxy and I usually write my code in Spyder; not sure if that has anything to do with it. Any ideas?
I'm also using python 2.7 64bit/weave.inline under windows 7 and just met the same issue as you described here. I searched the whole internet but this post seems like the only related one and i got no answer.
I traced the weave.inline function and try to load the pyd from compiled binary. Then i found that the loading is successful if i try
python -c "import sys; sys.path.insert(0, 'C:\\Users\\zliu\\AppData\\Local\\Temp\\zliu\\python27_compiled'); import sc_d4c0ee9cff8db6a9b5fc8352299944210;" where the module name being some hash value apparently.
However if I start python interactive then input the exact same statements in the interactive mode, it just shows
ImportError: DLL load failed: Invalid access to memory location.
So next i tried to compare the output of python -c -v "..." and python -v, finally i was able to locate the devil different line:
import string
I have no idea why python -c and python interactive are different in this or why without this module the import show such an ambiguous message. But putting it at the beginning of the script just works for me.
I am sorry for posting to such an old thread, and I do not offer an working solution or exaplantion of the problem, it is just a comment. ImportError: DLL load failed: Invalid access to memory location. I encountered the same error when trying to make my own extension of Python programmed in C. Platform Windows 32-bit.
It was a real pain because this error appeared randomly in interactive as well as in non-interactive mode in all Python environments (Spyder, Notebook, plain console...). I compiled my code using MinGW and Python's distutils (command python setup.py install). The compilation gave no warnings or errors and produced pyd file to the correct directory. But when trying to import this module import example pro my Python code it irregularly crashed (usually only one out of five attempts to import the module succeeded).
Strange was that on another computer it worked just fine... Well, I finally found a workaround - I downloaded a newer version of MinGW (before I had used the version that comes packed in Qt SDK distribution) and compiled the module again. Then it worked with no more crashes. However I did not find any systematic solution or explanation. So I might have something to do with the compiler (maybe absence of its DLLs? I do not know exactly) that was used to generate the pyd file.