python-3.7

GAE - Python 3.7 - How to log?

主宰稳场 提交于 2019-12-22 08:44:51
问题 I have a google app engine project in python 3.7 in which I would like to write some logs. I am used to program in app engine python 2.7 and I was using the simple code: logging.info('hi there!') to write any log onto the google cloud log console. That command above now doesn't work anymore and it says: logging has no attribute 'info' I searched and I found this possible new code from flask import Flask from google.cloud import logging app = Flask(__name__) @app.route('/l') def hello():

Difference in status of the same request over tor in python3.6 and python3.7

纵饮孤独 提交于 2019-12-22 01:19:12
问题 I have a request over tor that used to worked in python3.6. I switched to python3.7 and now I get 403 response status. Below is a way to replicate the issue with conda environments and requests: In python3.6: conda create -n python3.6 python=3.6.5 conda activate python3.6 conda install requests conda install ipython[all] ipython import requests session = requests.session() session.proxies = {} session.proxies['http'] = 'socks5h://localhost:9050' session.proxies['https'] = 'socks5h://localhost

tensorflow import issue for python 3.7

≡放荡痞女 提交于 2019-12-20 05:11:33
问题 After installing tensorflow for python 3.7, I tried to import it but it gave me a syntax error. the command used for installation : sudo -H pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl I don't think tensorflow has supported python3.7 yet. Is there a way to fix it? enter image description here 回答1: You can solve this by simply changing the name of all these ( Ctrl + R and Replace All ) from async to for example async1 as also this

Can't install pyHook package “Could not find a version that satisfies the requirement pyHook”

倖福魔咒の 提交于 2019-12-20 02:52:38
问题 im trying to install the pyHook package in pycharm but get the error in the title. I have successfully installed it in cmd with pip install pyHook-1.5.1-cp37-cp37m-win_amd64.whl ,but when I go to install it in pycharm I get the aforementioned error : Collecting pyHook Could not find a version that satisfies the requirement pyHook (from versions: ) No matching distribution found for pyHook 回答1: I ran into this problem myself, and after alot of searching, found that although pyhook has wheels

How to add a dataclass field without annotating the type?

半世苍凉 提交于 2019-12-19 14:58:31
问题 When there is a field in a dataclass for which the type can be anything, how can you omit the annotation? @dataclass class Favs: fav_number: int = 80085 fav_duck = object() fav_word: str = 'potato' It seems the code above doesn't actually create a field for fav_duck . It just makes that a plain old class attribute. >>> Favs() Favs(fav_number=80085, fav_word='potato') >>> print(*Favs.__dataclass_fields__) fav_number fav_word >>> Favs.fav_duck <object at 0x7fffea519850> 回答1: The dataclass

pip no longer working after update error 'module' object is not callable

廉价感情. 提交于 2019-12-17 07:16:09
问题 After a pip update, pip has stopped working completely. Z:\>pip install matplotlib Traceback (most recent call last): File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\program files\python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Program Files\Python37\Scripts\pip.exe\__main__.py", line 9, in <module> TypeError: 'module' object is not callable Any help please? Edit: I am working on windows 10 回答1: All

What are data classes and how are they different from common classes?

江枫思渺然 提交于 2019-12-17 07:02:42
问题 With PEP 557 data classes are introduced into python standard library. They make use of the @dataclass decorator and they are supposed to be "mutable namedtuples with default" but I'm not really sure I understand what this actually means and how they are different from common classes. What exactly are python data classes and when is it best to use them? 回答1: Data classes are just regular classes that are geared towards storing state, more than contain a lot of logic. Every time you create a

Csv file into seperate files

≯℡__Kan透↙ 提交于 2019-12-13 12:50:29
问题 I need to separate few csv files to incoming and outgoing traffic based on column values. This code doesn't give any output nor any error. if source == ac:37:43:9b:92:24 && Receiver address == 8c:15:c7:3a:d0:1a then those rows need to get written to .out.csv files. if Transmitter address == 8c:15:c7:3a:d0:1a && Destination== ac:37:43:9b:92:24 then those rows need to get written into .in.csv files. import csv import os import subprocess startdir = '.' outdir = '.' suffix = '.csv' def decode_to

Is it possible to detect pairs of connected pixels?

时光怂恿深爱的人放手 提交于 2019-12-13 03:43:48
问题 I'm using OpenCV via Python 3.7. I have a following image (please take note of some red pixels on white areas): I know x and y coordinates of every red pixel in the image. I want to find all red pixels pairs that're interconnected by single white lines. Let's label every red pixel with id (blue number): As you can see, the topmost red pixel labeled "1" has only two straight connections: one with a red pixel labeled "2" and one with a red pixel labeled "3". I'd like to get a list of tuples,

ValueError: The truth value of an array… from dict key comparison

非 Y 不嫁゛ 提交于 2019-12-13 03:28:51
问题 I can't figure out why I keep getting this error: if node not in self.children: return path ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() def _select(self, node): "Find an unexplored descendent of `node`" path = [] while True: path.append(node) breakpoint() if node not in self.children: return path if node.is_terminal(): return path self.children is a dict() of set() of Nodes. node is obviously a Node I get the same error in debugger