AttributeError: __enter__ using with statement SqlAlchemy session

I'm getting this AttributeError: __enter__ when I try to use SQLAalchemy session like in this guide. My code: Session = scoped_session(sessionmaker(autoflush=True, autocommit=False,...

How I can convert file with any format to text format using Python 3.6?

I am trying to have a converter that can convert any file of any format to text, so that processing becomes easier to me. I have used the Python textract library. Here is the documentation: ...

Import error running unittest in Python3

I have a problem importing files in Python 3.6. My directories tree is as given below: project/ app/ ├── __init__.py ├── a.py └── b.py test/ ├──...

Getting the default font in Tkinter

I'm running Python 3.6 and was wondering if there is a way to get the default font that Tkinter uses, more specifically the default font that the Canvas object uses when canvas.create_text is called.

How can I access command prompt history with Python

On Windows 10, Python 3.6 Let's say I have a command prompt session open (not Python command prompt or Python interactive session) and I've been setting up an environment with a lot of...

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

I am using Python 3.6. When I try to install "modules" using pip3, I face this issue: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

Why does unittest require __init__.py to be present in Python 3.6?

I just come across this line in python3.6 unittest (/usr/lib/python3.6/unittest/loader.py:286): is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py')) which caused the...

Python install error "A newer version of the Python launcher is already installed"

I am trying to reinstall Python, so I go control panel > uninstall > Python 3.6.2. It succeeds, but when I try to download 3.6.*, it says that I can't download because there is already a version...

xml.parsers.expat.ExpatError: not well-formed (invalid token)

When I use xmltodict to load the xml file below I get an error: xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 1 Here is my file: <?xml version="1.0"...

error LNK2001: unresolved external symbol PyInit_

I am trying to follow this tutorial to be abe to use C code in python. http://dfm.io/posts/python-c-extensions/ here is the gist...

The system cannot find the path specified error while running pyspark

I just downloaded spark-2.3.0-bin-hadoop2.7.tgz. After downloading I followed the steps mentioned here pyspark installation for windows 10.I used the comment bin\pyspark to run the spark & got...

write json float in scientific notation

I would like to represent floats in a JSON file in scientific notation using Python 3.6+. None of import json a = 0.001234567 print(json.dumps(a)) json.encoder.FLOAT_REPR = lambda x:...

How to control the mouse in Minecraft using Python?

All in all, I'm trying to programmatically -and externally- control the Minecraft player's orientation. No APIs, no Java mods to the game environment Typically this requires the movement of the...

pathos pool statement gets hanged

My program seems to not proceed further beyond the Pool(5) statement. I am using python 3.6 on windows server, 64 bit virtual machine with 8 virtual CPU's. Code is as below import...

python ctypes issue on different OSes

I'm trying to convert C function for python 3.6 use. code as below: lib = ctypes.WinDLL('ftrScanAPI.dll') # provided by fingerprint scanner class FTRSCAN_IMAGE_SIZE(ctypes.Structure): _fields_...

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(): ...

How to limit number of CPU's used by a python script w/o terminal or multiprocessing library?

My main problem is issued here. Since no one has given a solution yet, I have decided to find a workaround. I am looking for a way to limit a python scripts CPU usage (not priority but the number...

Mask-RCNN with Keras : Tried to convert 'shape' to a tensor and failed. Error: None values not supported

I am trying to run the Keras implemention of Mask_RCNN in inference mode. It is basically running this code demo.ipynb But when I run it, I get the following error on model creation : ValueError:...

Tensorflow Data Adapter Error: ValueError: Failed to find data adapter that can handle input

While running a sentdex tutorial script of a cryptocurrency RNN, link here YouTube Tutorial: Cryptocurrency-predicting RNN Model, but have encountered an error when attempting to train the model....

Connecting to Siemens NX server from python (NXOpen); pythonnet GetObject TypeError

I am trying to grab the Session object from a Siemens NX server (on the same machine, i.e. localhost). I am using python 3.6 with pythonnet, since the remote connection (apparently) only works...

Loading audio file to template causes ConnectionResetError: [Errno 54] Connection reset by peer (Django, Python)

I am making an audio player webapp using Django. The audio files are uploaded by admin via a model that adds the file to my Media directory. Then in my template the audio files are displayed with...

certbort commands return ModuleNotFoundError: No module named '_cffi_backend'

I followed a guide to get my python flask app running and I am at the last step where I change http into https with certbot. But when I run my certbot command sudo certbot --nginx -d domainname -d...

Discord Application Bot Python 3.6

currently I am working on a discord bot for a server and need to implement a staff application command such as !staff-application. I am trying to make a it in dms so the bot dms the question and...

Error loading the keras package in R studio

I am using R4.0.1 and Rstudio1.3.959 on windows 10. I have installed tensor flow: install.packages("tensorflow") library(tensorflow) install_tensorflow(method = "conda", conda_python_version =...

Installation of earlier versions of Python (prior to 3.8) fails on Mac with M1 Chip (ARM based Apple Silicon)

I have Macbook with Apple M1 Chip in which I have to use Python 3.6.5 for my project. It comes with Python 2.7.16 and 3.8.2 preinstalled. I used brew to install Python which by default installed...

GPU underutilized in Actor Critic (A2C) Stable Baselines3 implementation

I am trying to use A2C of StablesBaselines3 for training an agent on my custom environment. My problem is that my GPU Utilization is very less (around 10 % only) while my CPU utilization has hit...

Cannot install psycopg2 with pip3 on M1 Mac

I cannot install psycopg2 on my M1 Mac and I used pip3. When I tried to install with pip3 install psycopg2 The output like that: ERROR: Command errored out with exit status 1: command:...

AWS CLI not working because of unsupported Python version

I'm trying to download the AWS CLI tools onto my mac. The error message is pretty clear Unsupported Python version detected: Python 2.7 To continue using this installer you must use Python 3.6 or...

Python3 and 'code' CLI not working after updating to MacOS Monterey

I updated to MacOS Monterey and now python is not working: ➜ ~ python3 --version dyld[6578]: dyld cache '/System/Library/dyld/dyld_shared_cache_x86_64h' not loaded: syscall to map cache...

Tensorflow setup in R | Error: Failed to load the native TensorFlow runtime

For the last 5 days, I am trying to make Keras/Tensorflow packages work in R. I am using RStudio for installation and have used conda, miniconda, virtualenv but it crashes each time in the end....