python-3.2

Python3.2: Installing MySQL-python fails with error “No module named ConfigParser”

▼魔方 西西 提交于 2019-12-06 10:13:31
问题 I want to use SQLAlchemy with MySQL database. I've created the Engine and tried to connect but I get an error as follows. from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base Engine = create_engine('mysql+mysqldb://dbuser:pass@localhost/mydb') Base = declarative_base(Engine) That fails with the error: File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/connectors/mysqldb.py", line 57, in dbapi return __import__('MySQLdb'

Finding the baseaddress of a running process

社会主义新天地 提交于 2019-12-06 03:34:49
Ive got the following code: import subprocess from ctypes import * #-Part where I get the PID and declare all variables-# OpenProcess = windll.kernel32.OpenProcess ReadProcessMemory = windll.kernel32.ReadProcessMemory processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, PID) ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead)) All this is working flawless, but since some processes uses a so called BaseAddress or StartAddress . And in my case the size of this BaseAddress is random from time to time. As suggested here I tried using the following code: BaseAddress =

PyFile_Type replaced by ..?

…衆ロ難τιáo~ 提交于 2019-12-06 02:29:43
I'm tyring to compile Yenc for Python 3.2. I noticed that gcc complained about a non-declared function PyString_Type , so I replaced it with its replacement PyBytes_Type as according to the documentation . However, gcc also complained about an undeclared function called PyFile_Type . I googled a bit and found: Python 3.x replaces the PyFile_Type extension type with an abstract interface and specific implementation types. Unfortunately it doesn't make any of this directly available with a C level api. source I am by no means a C-programmer, which leaves me unable to solve this issue. What

DreamPie doesn't work with Python 3.2

谁说我不能喝 提交于 2019-12-05 17:54:57
My favorite Python shell is DreamPie and I want to use it with Python 3.2. I've used the "add interpreter" DreamPie app and added Python 3.2. When opening the Python 3.2 DreamPie instance I get the following error message: Indeed, Python 3.2 isn't mentioned on the DreamPie website as supported, but I still want to know if there's a way to make it work anyway. A quick search of the DreamPie issues found Can't launch python 3.2 which contains the following workaround in the first comment: To fix the issue edit \dreampie\subp_main.py , replace: sys.setdefaultencoding('utf-8') with: import

How do I change a Gtk3 Entry text color in Python3?

拈花ヽ惹草 提交于 2019-12-05 13:21:49
I have a list of Gtk.Entry() in my application, and I would like to change the color of the text of some of them. I tried the following : #!/usr/bin/python3 # Filename: mywindow.py from gi.repository import Gtk from gi.repository import Gdk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="My window") self.mainGrid = Gtk.Grid() self.add(self.mainGrid) self.myOkEntry = Gtk.Entry() self.myOkEntry.set_text("This is OK (green)") self.myOkEntry.override_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.0, 1.0, 0.0, 0.0)) self.mainGrid.add(self.myOkEntry) mainWin = MyWindow()

How do you make an installer for your python program

扶醉桌前 提交于 2019-12-05 08:59:02
Im new to python, but I was thinking about making a program with python to give to my friends. They don't know much about computers so if I asked them to install python by them selves they couldn't do it, but what if I could make an installer that downloads some version of python that only has what is needed for my file to run and make an exe file that would run the .py file in its own python interpreter . I also did a Google search and saw the freezing applications I could use to make the code into exe files to distribute (cx_freeze I use python 3.2), but not all of my friends have Windows

can't not install Distribute, zlib

寵の児 提交于 2019-12-05 08:44:17
At first, I only want to use install feedparser with python3.2, while it need Distribute. When I install Distribute with python3.2 setup.py install I got File "/usr/local/lib/python3.2/zipfile.py", line 687, in __init__ "Compression requires the (missing) zlib module") RuntimeError: Compression requires the (missing) zlib module Then I downloaded zlib and installed it with ./configure --prefix=/usr/local/python3.2 make sudo make install After the installation, and tried to install Distribute, I got the same error. Finally, I solved it by re-install python3.2 with zlib. 1 Of course, you need to

Why do I get “ImportError: cannot import name find_spec” when I start a new Django project?

痴心易碎 提交于 2019-12-04 22:24:43
I'm learning Python in tandem with Django. I initially installed Python 3 on my machine (Debian Wheezy), but read about possible conflicts and removed it with some difficulty. Now I'm using virtualenv and installed python3 within the env and Django using pip. Django and Python seem to have installed correctly: # python -c "import django; print(django.get_version())" 1.9.1 # python -V Python 3.2.3` but when I try to start a new Django project, I get the following: # django-admin.py startproject mysite Traceback (most recent call last): File "/home/rialaado/Projects/webenv/bin/django-admin.py",

AttributeError: 'Pool' object has no attribute '__exit__'

隐身守侯 提交于 2019-12-04 21:16:28
问题 I'm doing some multiprocessing python scripts using multiprocessing.Pool . These scripts look like the following: from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': with Pool(processes=4) as pool: # start 4 worker processes print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]" When running this with Python 3.4, everything is fine. However, when using Python 2.6 or 3.1 I get this error: AttributeError: 'Pool' object has no attribute '__exit__' Using Python 2

Hashing an immutable dictionary in Python

无人久伴 提交于 2019-12-04 16:29:45
问题 Short version: What's the best hashing algorithm for a multiset implemented as a dictionary of unordered items? I'm trying to hash an immutable multiset (which is a bag or multiset in other languages: like a mathematical set except that it can hold more than one of each element) implemented as a dictionary. I've created a subclass of the standard library class collections.Counter , similar to the advice here: Python hashable dicts, which recommends a hash function like so: class FrozenCounter