Autoload in Python

In the past I've used perl's AUTOLOAD facility for implementing lazy loading of symbols into a namespace, and wanted the same functionality in python. Traditionally the closest you appear to be...

How to retrieve the schema from MS Server Compact Edition (*.sdf) by using adodbapi?

I am trying to get the schema out of a database, before applying any queries from a local file (*.sdf). So far, I can connect to the database and perform queries when I know the schema. I have...

How to test a Connexion/Flask app?

I'm using the Connexion framework for Flask to build a microservice. I would like to write tests for my application using py.test. In the pytest-flask doc it says to create a fixture in...

Siamese Network using Rstudio Keras

I'm trying to implement a siamese network using Rstudio Keras package. The network I'm trying to implement is the same network that you can see in this post. So, basically, I'm porting the code to...

Use sklearn TfidfVectorizer with already tokenized inputs?

I have a list of tokenized sentences and would like to fit a tfidf Vectorizer. I tried the following: tokenized_list_of_sentences = [['this', 'is', 'one'], ['this', 'is', 'another']] def...

Password Protecting an Excel file using Python

I am trying to password protect an entire Excel file (same functionality as File > Protect Workbook > Encrypt with Password) using Python. I have come across openpyxl and the protection features...

AttributeError: 'module' object has no attribute 'mkdirs'

While creating a nested directory in Python 3.6 received following error: AttributeError: 'module' object has no attribute 'mkdirs' Sample code: def create_sample_data(): ...

Can't load tensorflow (tf-agent) saved model

I am creating a tf-agent DqnAgent in the following code: tf_agent = dqn_agent.DqnAgent( train_env.time_step_spec(), train_env.action_spec(), q_network=q_net, optimizer=optimizer, ...

Negative accuracy score in regression models with Scikit-Learn

I wrote a code that predicts house prices. The problem is, Im getting negative accuracy score. I have used 5 different algorithms and accuracy score is all over the place. The first problem that...

How to fix: AttributeError: module 'tensorflow' has no attribute 'contrib'

I'm training a LSTM and I'm defining parameters and regression layer. I get the error in the title with this code: lstm_cells = [ tf.contrib.rnn.LSTMCell(num_units=num_nodes[li], ...

AttributeError: 'str' object has no attribute 'find_element'

I am a novice in learning selenium with python. Problem Statement:- Getting the following error while trying to identify an object in the chrome browser. AttributeError: 'str' object has no...

When the method is called it is returning AttributeError

In this code, there's a Person class that has an attribute name, which gets set when constructing the object. It should do:1) when an instance of the class is created, the attribute gets set...

Modify code to be compatible on TensorFlow 2.3.0 (keras)

I got a tool that runs on TF1, but when I installed TF2 it stopped running because changes in the TF version. I need you help to update the code so that it will run on TF2. The code is is...

'OneHotEncoder' object has no attribute 'transform'

I am using Spark v3.0.0. My dataframe is: indexer.show() +------+--------+-----+ |row_id| city|index| +------+--------+-----+ | 0|New York| 0.0| | 1| Moscow| 3.0| | 2| Beijing| ...

How to convert grpc.ServerInterceptor to grcp.aio.ServerInterceptor

I am trying to implement async ServerInterceptor [grcp.aio.ServerInterceptor]. My current synchronous ServerInterceptor looks like this...

AttributeError: module 'google.cloud.vision' has no attribute 'types'

I did the setup for using the Google Vision API via Python, but it doesn't work and I don't find any good solutions. No matter what I do, I always get "AttributeError: module 'google.cloud.vision'...

Environment Variable not loading with load_dotenv() in Linux

I'm trying to make a discord bot, and when I try to load a .env with load_dotenv() it doesn't work because it says Traceback (most recent call last): File "/home/fanjin/Documents/Python...

Convert TF 2 saved model to frozen graph - no attribute model.inputs[0]

I created/trained a model via TF 2.4 (w/ CUDA 11.0, Python 3.7) /models/research/object_detection tutorial. No errors, appears to have run fine for 25000 steps. Everything looked normal,...

discord.py, send message by channel id without on_message() event?

i made a class for my bots config and general things in my code, im tidy so, client is discord.Client() and bot. is my class in my bot class i stored some channel ids and then i noticed...

AttributeError: 'Simple_Imputer' object has no attribute 'fill_value_categorical'' in PyCaret

I am using PyCaret and get an error. AttributeError: 'Simple_Imputer' object has no attribute 'fill_value_categorical' Trying to create a basic instance. !pip install pycaret==1.0 from...

module 'tensorflow.python.keras.backend' has no attribute 'slice'?

I am trying to implement https://github.com/ec-jrc/GHS-S2Net this project (in google colab). A week ago it was working by installing the requirements: !pip install tensorflow-gpu==2.0.0 !pip...

Flask-Restx Swagger Doc issue

I am getting AttributeError: module 'flask_restx.api' has no attribute 'doc' when it try add additional for API when using flask restx. How this error can be fixed. api.py from flask import...

Why am I Unable to install flask (PIP error)?

I am Unable to install Flask or nearly any other modules. My OS: Ubuntu 14.04 LTS (32bit). Ubuntu Comes with pre installed Python2 and Python3. As I had work with flask, I tried to install it with...

Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'

Im attempting to find model performance metrics (F1 score, accuracy, recall) following this guide...

Boto3 wait_until_exists for available image (object has not attribute)

I'm creating an AMI and I want to wait until the AMI is 'available'. I'm using the following code: import json import boto3 import os import logging ec2 = boto3.client('ec2') images =...

Tweepy error 'API' object has no attribute 'me'

I am trying to run the code from https://github.com/CreepyD246/Twitter-Reply-Bot/blob/main/TwitterReplyBot.py on Replit. #Importing modules/libraries import tweepy import time import os #...

AttributeError: module 'pyparsing' has no attribute 'downcaseTokens' rasa

I am facing a problem working with rasa, i can't run or train or do anything because below error. Traceback (most recent call last): File "c:\users\dell\anaconda3\envs\rasanew\lib\runpy.py",...

Celery unable to use redis

Trying to start Celery first time but issues error as below, i have installed redis and its starting fine , but still somehow django seems to have issues with it , File "<frozen...

TweepError: Twitter error response: status code = 403

I'm trying to extract the amount of #btc since 2019-01-01 per day. I know the error is about permission, but I'm already using the keys generated from Twitter developer's portal. Here's my code, I...

Python upgrades results in "AttributeError: module 'collections' has no attribute 'MutableMapping'" error when starting shell

I just upgraded to Python 3.10 on Mac OS X Big Sur. When I fire up the shell now, I get an error $ python manage.py shell ... Traceback (most recent call last): File...