python-3.7

Datetime strptime issue with a timezone offset with colons

不羁岁月 提交于 2020-07-07 06:03:19
问题 Currently we are working on an application which is trying to calculate the travel time of a route from a to b, using the 2.db.transport.rest API. Unfortunatly we are receiving timestamps with a timezone offset from that API, such as +01:00 . What we need is a timezone offset without the : , so +0100 . The following example gives an error on Linux, using Python 3.6.7: from datetime import datetime datetimestring = "2019-01-19T15:13:00.000+01:00" datetime.strptime(datetimestring, '%Y-%m-%dT%H:

Asyncio in corroutine RuntimeError: no running event loop

不羁岁月 提交于 2020-07-07 04:08:11
问题 I'm writing multi-process code, which runs perfectly in Python 3.7. Yet I want one of the parallel process to execute an IO process take stakes for ever using AsyncIO i order to get better performance, but have not been able to get it to run. Ubuntu 18.04, Python 3.7, AsyncIO, pipenv (all pip libraries installed) The method in particular runs as expected using multithreading, which is what I want to replace with AsyncIO. I have googled and tried looping in the main() function and now only in

removing stop words using spacy

二次信任 提交于 2020-07-05 11:41:05
问题 I am cleaning a column in my data frame , Sumcription, and am trying to do 3 things: Tokenize Lemmantize Remove stop words import spacy nlp = spacy.load('en_core_web_sm', parser=False, entity=False) df['Tokens'] = df.Sumcription.apply(lambda x: nlp(x)) spacy_stopwords = spacy.lang.en.stop_words.STOP_WORDS spacy_stopwords.add('attach') df['Lema_Token'] = df.Tokens.apply(lambda x: " ".join([token.lemma_ for token in x if token not in spacy_stopwords])) However, when I print for example: df.Lema

import pandas results in ModuleNotFoundError :_lzma

流过昼夜 提交于 2020-07-04 08:59:26
问题 On Ubuntu 18.04 with python 3.7.3, I'm attempting to import pandas but this fails because it can't find _lzma . I've verified that _lzma is installed with dpkg: /usr/lib/python3.7/lib-dynload/_lzma.cpython-37m-x86_64-linux-gnu.so. Oddly, _lzma is not a dependency of pandas (as specified by pip3). 回答1: I was running into this exact same issue today! I was able to fix it though. Pandas just put out a new version 0.25.0 on July 18th and changing the version back to 0.24.2 fixed this issue for me

Pygame : smooth picture aparition

删除回忆录丶 提交于 2020-06-29 06:54:20
问题 Can someone help me on this ? : I try to make a title that appear smoothly on the user screen : def image(name,x,y,u): screen.blit(name,(x,y)) if u = 1 pygame.display.update() Window == 'main' While windows = 'main': image(background,0,0) image(title, 640, 120) pygame.display.update() But texte appaers suddently and not as I would like... 回答1: You want to use transparency, and pygame uses three different types: There are three types of transparency supported in pygame: colorkeys, surface

Python3.7 venv does not Create Virtual Environment Directory

社会主义新天地 提交于 2020-06-27 18:31:10
问题 I'm trying to create a virtual environment in windows using: python3 -m venv <dir-name> When I check the contents of the current directory in cmd after running the above command, I don't see the venv directory show up. The command doesn't throw any errors. This person seems to have had the same problem: Python venv not creating virtual environment But the accepted answer was to re-install python, which didn't work for me. Other answers suggest installing virtualenv instead, but as far as I

No module named '_contextvars' in Python 3.7.3 virtual environment

会有一股神秘感。 提交于 2020-06-27 04:09:12
问题 I'm working on a Django project which requires Python3.7.3 virtual environment on Ubuntu 16 . So I created a virtual environment and installed all the requirements in it and verified it, activated it. But when I try to run the Django server using runserver it is giving me below error. Traceback (most recent call last): File "/usr/lib/python3.7/decimal.py", line 3, in <module> from _decimal import * ModuleNotFoundError: No module named '_decimal' During handling of the above exception, another

PyObjC “Notifications are not allowed for this application”

隐身守侯 提交于 2020-06-17 09:54:28
问题 I'm trying to test a simple Python script to send out a macOS notification: import objc import UserNotifications from PyObjCTools import AppHelper def notif_callback(err): print("Error in notification callback:",err) def auth_callback(granted, err): print("Granted: ",granted,) print("Error in authorization request: ",err) content=UserNotifications.UNMutableNotificationContent.alloc().init() content.setTitle_("Test") r=UserNotifications.UNNotificationRequest.requestWithIdentifier_content

Windows cmd doesn't recognize python or pip after installing mysql

a 夏天 提交于 2020-06-16 05:45:47
问题 I have installed MySQL through the MySQL installer. but after that, my cmd didn't recognize python, pip, and ipython anymore. whereas I did not change anything, just installed MySQL. before that, everything was working correctly. I expected to run python like always. but cmd shows me this : 'python' is not recognized as an internal or external command 回答1: I think you need to add Python to your local variables. It seems MySQL deletes it. Start the Run box and enter sysdm.cpl Go to the

How to move a no frame pygame windows when user click on it?

时光毁灭记忆、已成空白 提交于 2020-06-12 07:28:49
问题 i would create a pygame window that haven't frame but that move move when the user click on it and move the mouse. So I try this script but when I click on the windows, '0' printed but not '1' But something is wrong in my script # coding : utf-8 import pygame from pygame.locals import * from random import randint from os import environ from math import sqrt pygame.init() max_fps = 250 clock = pygame.time.Clock() window_size_x, window_size_x = 720, 360 infos = pygame.display.Info() environ[