python-3.6

Python subprocess.Popen doesn't take text argument

只谈情不闲聊 提交于 2020-02-24 10:45:21
问题 According to the Python 3 documentation for subprocess.Popen, the class constructor takes an optional argument text (which is supposed to control whether the file objects stdin, stdout and stderr are opened in text mode). However, when I try setting text=true upon construction of a Popen object, I get the error Failed: TypeError: __init__() got an unexpected keyword argument 'text' and when I look in the source code (I'm using Python 3.6.4), the constructor takes no argument text . What is

Test for import of optional dependencies in __init__.py with pytest: Python 3.5 /3.6 differs in behaviour

旧时模样 提交于 2020-02-24 03:54:10
问题 I have a package for python 3.5 and 3.6 that has optional dependencies for which I want tests (pytest) that run on either version. I made a reduced example below consisting of two files, a simple __init__.py where the optional package "requests" (just an example) is imported and a flag is set to indicate the availability of requests. mypackage/ ├── mypackage │ └── __init__.py └── test_init.py The __init__.py file content: #!/usr/bin/env python # -*- coding: utf-8 -*- requests_available = True

Selenium click() function (seemingly) randomly doesn't click the box [No errors][Python]

浪子不回头ぞ 提交于 2020-02-16 09:53:52
问题 I am new to selenium and am making a bot to automatically do trivia. The login works great, and so do most of the clicking boxes and going to the next question. Randomly they do not click the button, and also do not click for the next loop. This happens a lot towards the final questions (9 and over) but this could be coincidence. The very confusing this is that there is no error shown? The code finishes without errors Does anyone have any idea of why this is happening? Main Code from selenium

Selenium click() function (seemingly) randomly doesn't click the box [No errors][Python]

荒凉一梦 提交于 2020-02-16 09:53:35
问题 I am new to selenium and am making a bot to automatically do trivia. The login works great, and so do most of the clicking boxes and going to the next question. Randomly they do not click the button, and also do not click for the next loop. This happens a lot towards the final questions (9 and over) but this could be coincidence. The very confusing this is that there is no error shown? The code finishes without errors Does anyone have any idea of why this is happening? Main Code from selenium

openCV3: Not getting the expected output on morphologically transforming an image in opencv

。_饼干妹妹 提交于 2020-02-08 06:45:18
问题 I am trying to do top hat morphological transformation to an image but not getting the expected output for some reason. # Top Hat: difference between input image and opening kernel = np.ones((5,5),np.float32)/25 tophat = cv2.morphologyEx(img, cv2.MORPH_TOPHAT, kernel) plt.subplot(121),plt.imshow(img, cmap='gray'),plt.title('Original') plt.xticks([]), plt.yticks([]) plt.subplot(122),plt.imshow(tophat, cmap='gray'),plt.title('Top Hat') plt.xticks([]), plt.yticks([]) plt.show() What is expected

“No Backend Error” while reading files in Python

最后都变了- 提交于 2020-02-07 05:30:44
问题 I am trying to perform STFT on a bunch of sound files and I get this error. The path of the files which I am trying to perform STFT is correct but still, I get this error. import librosa import io import numpy as np import tensorflow as tf import os import glob path_te = "C:\Users\aanum\OneDrive\Documents\Deep Learning\timit-homework\te" files = os.listdir(path_te) for file in sorted(files): if file.startswith("tex"): file_path = path_te2 + "/" + file #file_path = 'r' + "'" + str(file_path) +

How to fix “Can't find a default Python” error

夙愿已清 提交于 2020-02-07 02:55:10
问题 I am using python in a windows server(64 bit) and it is installed by another user in his own directory in C:\user\userx\AppData\Local\Programs\Python\Python36 All other users (excluding me) are able to run Python files on this server. I get the following error when I run a Python programm: C:\Users\user x\AppData\Local\Programs\Python\Python36>test.py launcher build: 32bit launcher executable: Console File 'C:\Users\my user\AppData\Local\py.ini' non-existent File 'C:\Windows\py.ini' non

Python (3.6.3) argparse: default value of optional parameter to be another parameter's value

旧城冷巷雨未停 提交于 2020-02-06 07:58:50
问题 I have a function that takes as parameters an input folder (required) and output folder (optional), but I want the default value of the (optional) output folder to be the input folder. I can do this of course using, e.g. p = argparse.ArgumentParser(description="blah") p.add_argument('inpath', type=str, help="Path to input") p.add_argument('--outpath', required=False, type=str, help="Path to output") argin = p.parse_args() if argin.outpath is None: argin.outpath = argin.inpath but I want to

python 3.6 installation and lib64

馋奶兔 提交于 2020-02-05 02:50:48
问题 I'm trying to install the new Python (3.6, released just a few weeks back) from source on openSUSE 42.2. Everything ./configure --prefix /home/paul/2017 --enable-optimizations make make install appears to work just fine, but when I call the shiny new interpreter I get this error: Python 3.6.0 (default, Jan 9 2017, 22:01:27) [GCC 4.8.5] on linux Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "/home/paul/.pythonrc", line 7, in

Why does append overwrite the list?

坚强是说给别人听的谎言 提交于 2020-01-30 11:41:33
问题 I was trying some questions from hackerrank and came across this question https://www.hackerrank.com/challenges/list-comprehensions/problem I tried this solution if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) L = [] SL = [] for i in range(0, x + 1): for j in range(0, y + 1): for k in range(0, z + 1): if i + j + k != n: SL[:] = [] SL.append(i) SL.append(j) SL.append(k) print(SL) L.append(SL) print(L) although SL had the right solution I can't