attributeerror

AttributeError: __enter__ while trying to take input from microphone

一个人想着一个人 提交于 2020-02-25 06:38:27
问题 I had been trying to take input from microphone in my python program using speech_recognition I try to run this code: - import speech_recognition as sr import pyaudio r = sr.Recognizer() with sr.Microphone as source: audio = r.listen(source) text = r.recognize_google(audio) print(text) But it does not run. It says: - "C:\Users\Bravo Six\AppData\Local\Programs\Python\Python37-32\python.exe" "D:/BROTEEN/Works/Python/VALINI/speech testing.py" Traceback (most recent call last): File "D:/BROTEEN

AttributeError: module 'os' has no attribute 'chroot'

你说的曾经没有我的故事 提交于 2020-02-03 08:35:11
问题 Below is my very basic code running in spyder & python is choking, what am I doing wrong? import csv,os,sys path = os.getcwd() print (path) os.chroot(path) I get following error message: os.chroot(path) AttributeError: module 'os' has no attribute 'chroot' 回答1: One possibility is that your operating system is Microsoft Windows, for which os.chroot() is not available. 回答2: Did you name your file os.py ? If you did, it is shadowing the stdlib os module. Change the name of your file and delete

pyQt5 AttributeError: 'bool' object has no attribute 'txtCustCode'

佐手、 提交于 2020-01-25 08:14:10
问题 Using QT Designer to design the code. Then using the pyuic5 -x productentryscreen.ui > productentryscreen3.py command to generate python code. i am using buttons and textboxes. when a button is pressed i want to display value entered in the QlineEdit box. But i am getting the error " AttributeError: 'bool' object has no attribute" when the btnCancel is clicked. This is where the error is thrown (i presume) textboxValue = self.txtCustCode.text . i even tried with textboxValue = self

AttributeError at /admin/ by Django 'WSGIRequest' object has no attribute 'user'

﹥>﹥吖頭↗ 提交于 2020-01-24 14:14:07
问题 I cannot open the admin site, an error appears: 'WSGIRequest' object has no attribute 'user' Trying to enter in the site http://127.0.0.1:8000/admin/ I get this error: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 2.0.3 Python Version: 3.6.4 Installed Applications: ['polls', 'books', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles']

Importing packages in Python, attribute error

让人想犯罪 __ 提交于 2020-01-24 13:15:29
问题 I'm new in Python and I'm trying to understand how packages and import statement work. I made this package, located in my Desktop: package/ __ init __.py module2.py subpackage1/ __ init __.py module1.py Here's what's inside __ init __ .py in the package folder: __ all __ =["module2"] import os os.chdir("C:/Users/Leo--/Desktop/Package") import subpackage1.module1 os.chdir("C:/Users/Leo--/Desktop") and inside __ init __ .py in subpackage1 folder: __ all __ =["module1"] I want to import module1

AttributeError at /pre_pred/

送分小仙女□ 提交于 2020-01-24 00:53:07
问题 I've installed all the requirements and successful in running the local server but when I tried to run the prediction part of this 4th_umpire(The cricket match predictor using Random Forest algo project I'm getting the following error:- Here I'm presenting the error part of the code as mentioned in the error image. def _transform(self, X, handle_unknown='error'): X_list, n_samples, n_features = self._check_X(X) X_int = np.zeros((n_samples, n_features), dtype=np.int) X_mask = np.ones((n

Matplotlib, plotting pandas series: AttributeError: 'tuple' object has no attribute 'xaxis'

吃可爱长大的小学妹 提交于 2020-01-23 12:15:53
问题 I am plotting Pandas Series data, which records the sum of "events" each week in 1981. The series is named 'weekly_data'. 1981-03-16 1826 1981-03-23 1895 1981-03-30 1964 1981-04-06 1978 1981-04-13 2034 1981-04-20 2073 1981-04-27 2057 dtype: int64 I would like to place ticks by year, and by week. When I try to plot this, I receive an AttributeError: fig = plt.figure(figsize=(12,5)) ax = plt.subplots(111) plt.plot(weekly_data, color = 'green' ) yloc = YearLocator() mloc = MonthLocator() ax

Matplotlib, plotting pandas series: AttributeError: 'tuple' object has no attribute 'xaxis'

混江龙づ霸主 提交于 2020-01-23 12:15:29
问题 I am plotting Pandas Series data, which records the sum of "events" each week in 1981. The series is named 'weekly_data'. 1981-03-16 1826 1981-03-23 1895 1981-03-30 1964 1981-04-06 1978 1981-04-13 2034 1981-04-20 2073 1981-04-27 2057 dtype: int64 I would like to place ticks by year, and by week. When I try to plot this, I receive an AttributeError: fig = plt.figure(figsize=(12,5)) ax = plt.subplots(111) plt.plot(weekly_data, color = 'green' ) yloc = YearLocator() mloc = MonthLocator() ax

AttributeError: module 'time' has no attribute 'clock' in Python 3.8

ぃ、小莉子 提交于 2020-01-22 18:23:29
问题 I have written code to generate public and private keys. It works great at Python 3.7 but it fails in Python 3.8. I don't know how it fails in the latest version. Help me with some solutions. Here's the Code: from Crypto.PublicKey import RSA def generate_keys(): modulus_length = 1024 key = RSA.generate(modulus_length) pub_key = key.publickey() private_key = key.exportKey() public_key = pub_key.exportKey() return private_key, public_key a = generate_keys() print(a) Error in Python 3.8 version:

Pyinstaller Activex Attribute Error with wxPython

旧时模样 提交于 2020-01-16 13:29:23
问题 For some reason, when I compile my app with Pyinstaller, it gives me an error when run: Traceback (most recent call last): File "<string>", line 2, in <module> AttributeError: 'module' object has no attribute 'activex' And the top of my code (the code itself is extremely long). I've also removed a whole load of arrays at the top, which contain text for the app. from wxPython.wx import * from wx import * from wx.lib.wordwrap import wordwrap import sys, os, re class CheatulousFrame(wxFrame):