python-3.4

Django Call Stored Procedure on Second Database

故事扮演 提交于 2019-12-06 08:52:03
I'm trying to call a stored procedure on a multi-db Django installation, but am not having any luck getting results. The stored procedure (which is on the secondary database) always returns an empty array in Django, but the expected result does appear when executed in a mysql client. My view.py file from SomeDBModel import models from django.db import connection def index(request, someid): #Some related django-style query that works here loc = getLocationPath(someid, 1) print(loc) def getLocationPath(id, someval): cursor = connection.cursor() cursor.callproc("SomeDB.spGetLocationPath", [id,

Unable to install GDAL in python 3 using pip (clang failed with exit status 1)

*爱你&永不变心* 提交于 2019-12-06 07:20:13
问题 After running sudo pip3.4 install gdal from terminal (Mac OS X Mavericks) I obtain an error message saying that the 'col_port.h' file was not found and displaying the following error: command '/user/bin/clang/ failed with exit status 1 (the full message is below). I have gdal 1.11 (the complete framework version downloaded from kingchaos.com) and the most recent version of the Xcode command line tools -Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Here is the error that I get

Tkinter activate window on Windows XP

北城以北 提交于 2019-12-06 05:00:51
I have a small GUI application that listens for network messages so a user can update some info and accept it. This is in a production factory environment and used for interacting with a specific piece of physical hardware (over serial in some cases). The workflow looks like this: User is interacting with another program (5250 Green Screen) They enter a certain keybinding that sends a UDP message to a Tkinter GUI The Tkinter GUI does a deiconify() User edits data, accepts (Enter) and it does an iconify() My issue is that on windows XP, the GUI does not become active when I do the deiconify and

Nuitka on Windows

五迷三道 提交于 2019-12-06 04:36:16
问题 Having problems to compile hello-world.py using Nuitka on windows. The command I am using is: nuitka --standalone --portable --remove-output --recurse-all --python-version=3.4 hello_world.py The error is: WindowsError: [Error 2] The system cannot find the file specified: File "C:\Users\win_user\Anaconda3\Lib\site-packages\nuitka\build\SingleExe.scons", line 866: shell = False File "c:\Python27\lib\subprocess.py", line 709: errread, errwrite) File "c:\Python27\lib\subprocess.py", line 957:

Pyautogui TypeError: 'NoneType' object is not iterable

淺唱寂寞╮ 提交于 2019-12-06 03:44:22
问题 I'm trying to use locateCenterOnScreen() function of PyAutoGUI, however it raises : Traceback (most recent call last): File "C:\Users\windows\Desktop\asd.py", line 3, in <module> buttonx, buttony = pyautogui.locateCenterOnScreen('who.jpg') TypeError: 'NoneType' object is not iterable My code is: import pyautogui buttonx, buttony = pyautogui.locateCenterOnScreen('who.jpg') pyautogui.doubleClick(buttonx,buttony) How can I fix this problem? 回答1: From the documentation of Pyautogui here, the

Python ImportError: cannot import name '_imagingtk' in virtualenv

偶尔善良 提交于 2019-12-06 03:30:53
I wanted to start using pillow, but I ran into some problems: At first, I thought I could simply pip install pillow , so I activated my virtualenv and did exactly that. When it didn't worked, I realized that I need to install some dependencies for pillow ( installation ). I'm on Ubuntu 14.04. But even after I installed those dependencies and reinstalled pillow, the Code didn't work. Until I tried it outside of the virtualenv and pip installed pillow on my main Python3.4 installation, where my Code suddenly worked. import tkinter as tk from PIL import Image, ImageTk def show(img, text=""): root

Foreign Key Reference for Django in Admin

余生颓废 提交于 2019-12-06 02:35:13
问题 I have been trying to solve this issue in Django admin but still cannot find the documentation. In my models.py , I have the following code: from django.db import models class Post(models.Model): title = models.CharField(max_length=200) author = models.ForeignKey('Author', blank=False) class Author(models.Model): first_name = models.CharField('First Name',max_length=50) last_name = models.CharField('Last Name', max_length=50, blank=True) description = models.CharField(max_length=500, blank

Unexpected error reading GML graph

时光毁灭记忆、已成空白 提交于 2019-12-06 02:16:02
问题 I have downloaded the gml file which contains the dolphins social network. Some time ago I did some analysis on that network running python 3.4 and networkx 1.9 on a a Windows7 machine, but now I am running on a Arch linux machine (with the same version of python but with networkx 1.10 ) and found an issue when tried to read the file. This is the code used to read the file: import networkx as nx nx.read_gml("dolphins.gml") And this is the stack trace of the error: Traceback (most recent call

create .deb package by python setup.py

天涯浪子 提交于 2019-12-06 01:36:03
i want create .deb package for my python program. i create setup.py and it works well, but when I want to create a debian package using setup.py and stdeb I get an error. the commands I use to create .deb: first: python3.4 setup.py sdist then: python3.4 setup.py --command-packages=stdeb.command bdist_deb but get error dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting dpkg-buildpackage: warning: (Use -d flag to override.) Traceback (most recent call last): File "setup.py", line 19, in <module> install_requires=['setproctitle', 'psycopg2', 'psutil'] File "/usr/lib

Get a random sample of a dict

旧城冷巷雨未停 提交于 2019-12-05 22:11:45
I'm working with a big dictionary and for some reason I also need to work on small random samples from that dictionary. How can I get this small sample (for example of length 2)? Here is a toy-model: dy={'a':1, 'b':2, 'c':3, 'd':4, 'e':5} I need to perform some task on dy which involves all the entries. Let us say, to simplify, I need to sum together all the values: s=0 for key in dy.key: s=s+dy[key] Now, I also need to perform the same task on a random sample of dy; for that I need a random sample of the keys of dy. The simple solution I can imagine is sam=list(dy.keys())[:1] In that way I