python-3.6

Converting Python 3.6 script to .exe? [duplicate]

折月煮酒 提交于 2019-12-13 03:16:03
问题 This question already has answers here : How can I convert a .py to .exe for Python? (6 answers) Closed 2 years ago . I would like to convert a .py file to an .exe. I am using Python 3.6. I already tried py2exe and PyInstaller but they don't seem to work properly with Python 3.6. Here is the traceback from PyInstaller. 回答1: So, let's try Pyinstaller first. $ pyinstaller script.py --onefile This will generate a script.spec file in the spec file you can remove the console, debug mode etc $

How to append text to a label using text from a file and an entry in tkinter python

≡放荡痞女 提交于 2019-12-13 03:15:19
问题 I am making a tkinter python project, which is a to-do list. The to-do list label uses text from the 'To-Do List.txt' file, whose contents just say 'To Do List:' I am trying to enter text into an entry function and, when I press the 'Add Item' button, the text in the entry should add to the text in the label, and the text in the label is basically the txt file. The entry should add to the txt file. How should I go about doing this? I do not know how. Here is my code so far. import tkinter as

UnicodeDecodeError while processing Accented words

筅森魡賤 提交于 2019-12-13 02:58:08
问题 I have a python script which reads a YAML file (runs on an embedded system). Without accents, the script runs normally on my development machine and in the embedded system. But with accented words make it crash with UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128) only in the embedded environment. The YAML sample: data: ã The snippet which reads the YAML: with open(YAML_FILE, 'r') as stream: try: data = yaml.load(stream) Tried a bunch of

how to use multiple .ui files in the main python file

妖精的绣舞 提交于 2019-12-13 02:35:22
问题 i have two .ui files that converted to python using pyuic5. first converted ui file is (LoginWindowUI.py) as below: from PyQt5 import QtCore, QtGui, QtWidgets class Ui_LoginWindow(object): def setupUi(self, LoginWindow): LoginWindow.setObjectName("LoginWindow") LoginWindow.setWindowModality(QtCore.Qt.NonModal) LoginWindow.setEnabled(True) LoginWindow.resize(446, 182) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0)

append list inside dictionary with update

做~自己de王妃 提交于 2019-12-13 02:01:02
问题 if i have below dictionary with one of the element is list, as follow: myDict = dict(a=1, b='2', c=[]) how do I update myDict and at the same time append c e.g. myDict .update(a='one', b=2, c=append('newValue')) myDict .update(a='1', b='two', c=append('anotherValue')) and the final result should be: myDict = a='1', b='two', c=['newValue', 'anotherValue'] in one statement.... 回答1: You can't use append within update because append is trying to perform an inplace operation on the dict value. Try

Django 1.11 on passenger_wsgi not routing POST request

梦想与她 提交于 2019-12-13 00:33:44
问题 I'm trying to setup python on A2 shared hosting via passenger_wsgi. The app is working fine when I run it via 'runserver'. I tested this both in my local PC, and via SSH tunnel. However, when I try to set this up on passenger_wsgi, it can't seem to be able to route POST request. 1 import os 2 import sys 3 4 sys.path.insert(0, "/home/<username>/app") 5 6 import APP_CORE 7 8 # where is the python interpreter 9 INTERP = "/home/<username>/app/.virtualenv/bin/python" 10 if sys.executable != INTERP

Matplotlib, refresh image with imshow faster

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 20:24:53
问题 I am working on a project on which I have to plot an image of 320*250 pixels and this 60 times per second if possible, on a window of a GUI. So I try to do this with matplotlib 2.0.2 , Python 3.6 and PyQt5 (because I begin to know these tools and work on another project with this), in the following way : import sys, random, matplotlib from PyQt5 import QtCore, QtGui, QtWidgets matplotlib.use('Qt5Agg') from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas import

NOT NULL constraint failed: user_profile.user_id

前提是你 提交于 2019-12-12 19:25:01
问题 I'm try to make Sign Up form With Profile Model and I will make some changes in the model. All tables are created when I run manage.py makemigrations but when I want to run manage.py migrate then is show this error: django.db.utils.IntegrityError: NOT NULL constraint failed: user_profile.user_id Model.py class Profile(models.Model): user = models.OneToOneField(User,default="", on_delete=models.CASCADE) bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length

Pygame slow after python update

怎甘沉沦 提交于 2019-12-12 17:22:24
问题 I am making a python game with pygame on my home computer for school running with python 3.6.3 and pygame 1.9.3. When working on my game I also worked at school where it was working correctly just slower as expected but when I started to load images it randomly choose the images and didn't load the correct ones on school computer not home one (I think this might be due to change in arrays and loading them). I soon found I was running python 3.5.3 at school and then when updating it the python

How to postpone/defer the evaluation of f-strings?

时间秒杀一切 提交于 2019-12-12 13:21:14
问题 I am using template strings to generate some files and I love the conciseness of the new f-strings for this purpose, for reducing my previous template code from something like this: template_a = "The current name is {name}" names = ["foo", "bar"] for name in names: print (template_a.format(**locals())) Now I can do this, directly replacing variables: names = ["foo", "bar"] for name in names: print (f"The current name is {name}") However, sometimes it makes sense to have the template defined