Questions tagged [python]

Python is a dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Please note that Python 2 is officially out of support as of 2020-01-01. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

638,667 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
24 votes
1 answer
903 views

Google Cloud Storage - PUT Fails on Development Server

On my dev server, Google Cloud Storage fails to save files during a PUT command. This same command works fine on production. The response headers (see below) have little debug information. I have ...
speedplane's user avatar
  • 15.8k
23 votes
2 answers
3k views

Workaround for lack of intersection types with Python generics?

I'm hitting an issue that would be easily solved by intersection types (currently under discussion but not yet implemented) and was wondering what the cleanest workaround is. Current setup and problem ...
Uri Granta's user avatar
  • 1,844
22 votes
1 answer
2k views

Graph optimizations on a tensorflow serveable created using tf.Estimator

Context: I have a simple classifier based on tf.estimator.DNNClassifier that takes text and output probabilities over an intent tags. I am able to train an export the model to a serveable as well as ...
o-90's user avatar
  • 17.2k
21 votes
3 answers
2k views

make tqdm bar dark in VSCode Jupyter notebook

I am using Jupyter notebooks in Visual Studio Code with dark mode enabled. I visualize progress bars with tqdm, but it does not show up dark. See the image: According to this issue on GitHub, this is ...
Sadra's user avatar
  • 2,560
21 votes
0 answers
2k views

Issues using Spyder python to connect to remote machine

So I have a RedHat System in AWS running Spark on top of HDFS. Now I want to access PySpark from my local machine i.e. Interactive Python. So, I installed Spyder-Py2 to connect to the remote AWS ...
Jason's user avatar
  • 2,326
21 votes
1 answer
1k views

Dealing with Concurrent Requests & Connections in Cloud SQL

We have created an app on App Engine using Datastore. Now we have been led to using Cloud SQL as we wanted to use joins, nested queries and functions such as average, total etc. Data gets migrated ...
Kartik Domadiya's user avatar
20 votes
1 answer
2k views

xgboost.plot_tree: binary feature interpretation

I've built an XGBoost model and seek to examine the individual estimators. For reference, this was a binary classification task with discrete and continuous input features. The input feature matrix is ...
blacksite's user avatar
  • 12.2k
20 votes
1 answer
22k views

libraries mkl_rt, openblas, lapack not found while installing scipy - How to change flags for libraries

I am new to python and pip ecosystem. I am trying to install scikit-image and it is installing scipy as a dependency I suppose. I am using macOS 11.1 and I know that support for this version is not ...
G Patel's user avatar
  • 301
19 votes
2 answers
1k views

Attention Layer throwing TypeError: Permute layer does not support masking in Keras

I have been following this post in order to implement attention layer over my LSTM model. Code for the attention layer: INPUT_DIM = 2 TIME_STEPS = 20 SINGLE_ATTENTION_VECTOR = False ...
Saurav--'s user avatar
  • 1,559
19 votes
2 answers
3k views

FastCGI, Lighttpd, and Flask

I'm setting up a simple web server on my Raspberry Pi and I can't seem to set up lighttpd, fastcgi, and flask correctly. By now, I've gone through a few iterations of /etc/lighttpd/lighttpd.conf, the ...
user1610406's user avatar
18 votes
0 answers
3k views

Resolving differences between Keras and scikit-learn for simple fully-connected neural network

I have built a fully-connected neural network in both scikit-learn (v 0.20.0) and Keras (v 2.2.4) with TensorFlow backend (v 1.12.0). There are 10 units in the single hidden layer. In both cases I ...
Finncent Price's user avatar
18 votes
0 answers
1k views

robobrowser won't change cookies

I have a POST request sent to server from robobrowser, and the server responds with no data. The response headers are as follows (this is the response from Chrome browser and it's the way it supposed ...
ikel's user avatar
  • 1,850
17 votes
2 answers
3k views

Install multiple private packages from Github using Poetry and deploy keys

I want to install multiple private Github repositories as python packages into my repository using poetry. This works fine when running poetry install locally as I have my public SSH key added to ...
Joachim's user avatar
  • 619
17 votes
0 answers
1k views

PySpark and Protobuf Deserialization UDF Problem

I'm getting this error Can't pickle <class 'google.protobuf.pyext._message.CMessage'>: it's not found as google.protobuf.pyext._message.CMessage when I try to create a UDF in PySpark. ...
Marc Vitalis's user avatar
  • 2,169
17 votes
3 answers
15k views

Response payload is not completed using asyncio/aiohttp

I've written a Python 3.7 script that asynchronously (asyncio 3.4.3 and aiohttp 3.5.4) creates a Salesforce bulk API (v45.0) job/batch using multiple objects queried by a single SOQL statement each, ...
gbeaven's user avatar
  • 1,648
17 votes
0 answers
10k views

Nested cross-validation example on Scikit-learn

I'm trying to work my head around the example of Nested vs. Non-Nested CV in Sklearn. I checked multiple answers but I am still confused on the example. To my knowledge, a nested CV aims to use a ...
NCL's user avatar
  • 385
17 votes
1 answer
1k views

Mutation for nested object

I'm trying to implement GraphQL mutation for a "complex" object. Let's say we have a Contact with three fields: firstName, lastName and address, which is object with one field street: Here ...
Pavel Reznikov's user avatar
17 votes
2 answers
11k views

mpiexec and python mpi4py gives rank 0 and size 1

I have a problem with running a python Hello World mpi4py code on a virtual machine. The hello.py code is: #!/usr/bin/python #hello.py from mpi4py import MPI comm = MPI.COMM_WORLD size = comm....
ziuu's user avatar
  • 356
17 votes
1 answer
528 views

How can I merge rankings from several Elasticsearch queries?

I would like to merge the rankings obtained from querying separate fields of an Elasticsearch index, so to obtain a "compound" ranking. As a (silly) "matchmaking" example, suppose I wanted to ...
Davide Fiocco's user avatar
17 votes
3 answers
4k views

list filter by custom list display field in django admin

I have following model admin. I'm displaying custom field in list view. class CustomerAdmin(admin.ModelAdmin): list_display = ('first_name', 'last_name', 'email', 'state') search_fields = ('...
Vijay's user avatar
  • 944
16 votes
0 answers
1k views

Create a QEMU Bridge Using the Socket Networking Backend

I am trying to create a bridge to an interface in my host, much like the Virtualbox's and VMWare's bridge adapters, in QEMU, using a combination of socket networking and a Python library called Scapy (...
falhumai96's user avatar
15 votes
1 answer
11k views

Connect to sql server from linux environment using putty private key, sqlalchemy and pyodbc

Hi I am trying to read a dataframe from sql server from a linux(ubuntu server). The file(gscm.ppk) has the admin keys in it I have used the following format to connect to sql server: import urllib....
nsk's user avatar
  • 161
15 votes
2 answers
2k views

How to configure VS Code's Integrated Terminal to use the correct Python Interpreter

TL;DR This question is NOT asking how to select a Python Interpreter to run, or debug, code with, furthermore; this question is NOT asking anything in regard to Virtual Environment, or how to activate ...
Mark Kortink's user avatar
  • 1,880
15 votes
0 answers
5k views

Reprojecting .tiff file with rasterio: CRSError: The WKT could not be parsed. OGR Error code 6

I am trying to re-projected a .tiff file to EPSG:32638 with the following code. Versions I have installed: Rasterio version 1.1.5 Numpy version 1.18.1 This is the code I am using:https://rasterio....
ecd's user avatar
  • 185
15 votes
3 answers
16k views

Install from pipfile using pipenv install gives error

I have a project where I'm trying to install from the pipfile using pipenv install. I get som error when installing. Before i describe the error, this is what I did: Reinstall pipenv Reinstall Python ...
BluePrint's user avatar
  • 1,966
15 votes
2 answers
7k views

'ImportError: No module named ...' when trying to import pyx file to Jupyter

I have this file em.pyx in the same folder as the Jupyter notebook where I try to import it but it is giving me the error ImportError: No module named em I've tried adding import sys sys.path....
AJHC's user avatar
  • 285
15 votes
0 answers
2k views

LSTM object detection tensorflow

Long story short: How to prepare data for lstm object detection retraining of the tensorflow master github implementation. Long story: Hi all, I recently found implementation a lstm object ...
Philipp F.'s user avatar
15 votes
0 answers
1k views

Single Thread Impacts Model Accuracy and Loss with TensorFlow Keras Backend

Question Why does setting the number of threads in the TensorFlow backend for Keras, intra_op_parallelism_threads and inter_op_parallelism_threads, to 1 negatively impact the accuracy and loss of a ...
user avatar
15 votes
1 answer
3k views

ProgrammingError: column "X" is of type double precision but expression is of type numeric[]

I am trying to program an API with Django Rest Framework and Psycopg2 library. This API works with PostgreSQL database. I need to store 2 float array fields in this db because the API works with 2 ...
Nacho Díaz Reyes's user avatar
15 votes
1 answer
9k views

How does autoreload work with jupyter?

I have a file mytest.py in the working directory, with the following content: class MyTest(object): def __init__(self): print(1) pass In jupyter I have these cells. Cell 1: %reload_ext ...
ceiling cat's user avatar
  • 5,561
15 votes
2 answers
3k views

User defined generic types and collections.abc

I have a Python package that defines a variety of collections based on the ABCs provided by collections.abc (Mapping, Sequence, etc). I want to take advantage of the type hinting facilities introduced ...
Marti Congost's user avatar
15 votes
1 answer
2k views

Saving multiple images in MayaVi

I want to render around 500 images and save them to different png files, therefore I wrote a small class which contains my dataset and a renderfunction from mayavi import mlab mlab.options.offscreen=...
jrsm's user avatar
  • 1,605
15 votes
1 answer
5k views

How to Configure Poetry Environments in Pycharm With Windows + WSL2?

TL;DR: can't configure a Python Interpreter on PyCharm (Windows) using an existing Poetry environment in WSL. When trying to set the Poetry environment path under Add Python Interpreter > Poetry ...
aon's user avatar
  • 361
15 votes
4 answers
9k views

How to print value of tensorflow.python.framework.ops.Tensor in Tensorflow 2.0?

I have a few tensors in my code and and need to get the values of those tensors. This is one them. How to print the values of tensor OA? Input:OA Output: <tf.Tensor 'Sum_1:0' shape=(1, 600) dtype=...
Raghu's user avatar
  • 427
15 votes
1 answer
13k views

Place to initialize DB in Flask

I'm developing app in Flask and it requires DB, so what I have is I do: app = Flask(__name__) @app.before_request def init_db_connection: # here I connect to my DB @app.teardown_request def ...
Ignas Butėnas's user avatar
15 votes
1 answer
1k views

matplotlib with pgf, error: dimension too large

In using the pgf backend of matplotlib, I sometimes see an error like this: ! Dimension too large. <to be read again> \advance l.69 ...o{\pgfqpoint{-11.400000in}{-235....
tsj's user avatar
  • 768
15 votes
3 answers
18k views

Is there a way to restart or reset the python interpreter within a python doctest?

I am writing a short tutorial, and would like to be able to run the examples therein using python's doctest using python -m doctest foo.txt There is a point in the tutorial at which I want to start ...
EHN's user avatar
  • 608
14 votes
1 answer
3k views

How to use python-poetry across architectures?

My primary development machine is x86_64 while some of my deploy environments are arm7vl (Raspberry Pi). For most Python development, this isn't a problem, but some Python libraries are are only ...
Daniel Quinn's user avatar
  • 6,120
14 votes
0 answers
10k views

Gunicorn With Gevent, Performance Gain

Gunicorn Worker Class Gunicorn has worker_class setting. Some possible values are sync gthread gevent Definitions from Luis Sena's nice blog sync This is the default worker class. Each process will ...
Kagan Coskun's user avatar
14 votes
1 answer
5k views

Is .NET Core or .NET 5.0 supported by Pythonnet

I've been using Pythonnet for quite some time but always against .NET Framework 4.* With the recent release of .NET 5.0 I wanted to migrate my projects but I could not make it work for non-Framework ...
jo31's user avatar
  • 177
14 votes
0 answers
10k views

Ignore pkg_resources.ContextualVersionConflict or ResolutionImpossible

I have built a python module which installs kwikapi==0.4.5 and requests==2.22.0. But kwikapi has requests==2.18.4. Now when I install and run my package, I am getting error pkg_resources....
Ram Idavalapati's user avatar
14 votes
1 answer
2k views

How can I add type hints to my monkey-patched function to an existing module's class?

I want to know how I can add type hints (for PyCharm IDE code completion support) to a method def links(self) -> List[str] that I monkey-patched to an existing module's class: My function def ...
Christopher Graf's user avatar
14 votes
2 answers
898 views

Airflow - Different schedule interval for backfilling

What's the best way to handle having a different schedule interval for backfilling and ongoing running? For backfilling I want to use a daily interval, but for ongoing running I want to use an hourly ...
Mark M's user avatar
  • 485
14 votes
0 answers
3k views

How to create custom filter using graphene-django and Relay that use multiple fields of different types?

Problem Hello, I'm using Graphene Django and Graphene Relay with Python 3.7. I'm trying to make a custom filter for the requests in GraphQL using Django filters. My table looks like this: | id(...
user avatar
14 votes
3 answers
5k views

ModuleNotFoundError: No module named 'math'

When I try to install a python version using pyenv, I get the following error: $ pyenv install 3.5.7 Downloading Python-3.5.7.tar.xz... -> https://www.python.org/ftp/python/3.5.7/Python-3.5.7.tar....
Dev Aggarwal's user avatar
  • 7,867
14 votes
2 answers
1k views

OperationalError: (sqlite3.OperationalError) too many SQL variables, while using SQL with dataframes

I have a pandas dataframe as below. activity User_Id \ 0 VIEWED MOVIE 158d292ec18a49 1 VIEWED MOVIE 158d292ec18a49 2 VIEWED MOVIE 158d292ec18a49 3 VIEWED MOVIE ...
Sarang Manjrekar's user avatar
14 votes
1 answer
1k views

Flask SERVER_NAME setting best pratices

Since my app has background tasks, I use the Flask context. For the context to work, the Flask setting SERVER_NAME should be set. When the SERVER_NAME is set the incoming requests are checked to match ...
Christof Haerens's user avatar
14 votes
1 answer
3k views

Transformed beta regression in python

Has anyone tried implementing beta transformed regression python? It is used to model values that lie between 0 and 1 and has a distribution with heteroskedasticity ineherently present. Essentially ...
user8947896's user avatar
14 votes
1 answer
1k views

Block jupyter notebook cell execution till specific message received

I'm trying to implement asynchronous, distributed computation engine for python, which is compatible with jupyter notebook. The system is supposed to be based on 'push notification' approach what ...
Maciej Nowicki's user avatar
14 votes
1 answer
415 views

Openface Flask Wrapper: Flask seems to be blocking a thread

I am trying to write a small flask REST API wrapper around the openface api so that I can POST image URLs to my flask server and have it run a comparison of the image against a classifier model app = ...
Brien Crean's user avatar
  • 2,639

1
2 3 4 5
12774