site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
Turns out that urllib3 version 2 wants OpenSSL to work properly. The earlier versions of urllib3 version 2 even stopped entirely, the later ones throw this warning. But my current ssl module appears to be LibreSSL. The idea is to install an urllib3 that is compatible with LibreSSL.
Solution
pip install urllib3==1.26.20
An older version of urllib3 series 1 works, I picked the latest. Now my app runs without the warning.
I want to read the config for my backend from a yaml file and when installing the yaml package I am getting the following error:
pip install yaml
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
ERROR: Could not find a version that satisfies the requirement yaml (from versions: none)
ERROR: No matching distribution found for yaml
I came across a problem where my Tensorflow installation did not recognize the installed gpu, despite of Cuda and Nvidia drivers being installed properly.
test:
python3 -c “import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU’))”
returned an empty list. Furthermore, it tells it cannot find the cuda library:
2024-01-30 14:57:42.015454: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
Output of the Nvidia tool is correct and shows Cuda is installed:
nvidia-smi
ubuntu@ip-bla-foo:~/build-nb$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Mon_Apr__3_17:16:06_PDT_2023 Cuda compilation tools, release 12.1, V12.1.105 Build cuda_12.1.r12.1/compiler.32688072_0
Test: python3 -c “import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU’))”
2024-01-30 15:27:04.458720: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2024-01-30 15:27:04.458772: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2024-01-30 15:27:04.459601: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2024-01-30 15:27:04.465334: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-01-30 15:27:05.115551: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT 2024-01-30 15:27:05.560865: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355 2024-01-30 15:27:05.585883: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355 2024-01-30 15:27:05.586100: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355 [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
When you click on an applications exe file and nothing happens, you might wonder what it does (if anything) and find a way to debug what is happening. By default, the binary does not output any log to the console. But there is a way to do that.
You can rebuild your Qt app using the console qmake flag in order to get some useful debugging output on the console.
CONFIG += console
either in your QtCreator Build Settings or as a command line argument to qmake. Then run the app exe from a Windows terminal such as PowerShell and you will see the same output you would see in QtCreator, including your qDebug outputs. You can also click on it in the explorer and it opens a standard terminal showing the console output.
This can be very useful, e.g. when debugging a sandbox created with windeployqt.
Uncover the Root of Errors with Detailed Tracebacks
Encountering errors in Python is inevitable. But with stack traces, you can pinpoint the exact location of an exception and diagnose issues effectively. Here’s a step-by-step guide:
1. Import the traceback Module:
import traceback
2. Utilize Exception Handling:
try: processEvent() # Call the function that might raise an exception except Exception as e: print("Error encountered:", e) traceback.print_exc() # Print the detailed stack trace
Key Points:
traceback.print_exc(): Prints a formatted traceback to the console.
Error Message: The print("Error encountered:", e) line displays the error message itself.
Traceback Structure:
Each line represents a function call leading to the exception.
The topmost line indicates the most recent call, and subsequent lines trace the sequence backward.
Example Output:
Error encountered: An error occurred! Traceback (most recent call last): File "<stdin>", line 2, in <module> File "<stdin>", line 2, in processEvent Exception: An error occurred!
Leave a comment, or reach out if you have a question.
Additional Insights:
Customizing Output:
traceback.format_exc() returns the formatted traceback as a string for further manipulation.
traceback.print_exception() offers more control over output formatting.
Logging Stack Traces: Consider logging stack traces for debugging or analysis purposes.
Troubleshooting with Confidence:
By effectively printing and understanding stack traces, you’ll be equipped to resolve Python exceptions efficiently and maintain code stability.
After upgrading my Macbook to BigSur (I skipped Catalina) my MongoDB didn’t want to start anymore. A quick inspection showed that the /data/db folder I used to have to house my db files didn’t exist anymore. BigSur has removed it 😱 but luckily I found a backup.
It appears that the root / folder on MacOS is now readonly, and I wasn’t able to copy the backup to its original place. I chose the Mac disk instead, and it now sits in /System/Volumes/Data/data
What was left is to create a symlink to /data, and the way to do that is by using the /etc/synthetic.conf file:
data /System/Volumes/Data/data
This fixes the /data folder I used to have for MongoDB.
In SDK 29 it was working, but in SDK 30 and 31 bindService() returned always false and did not throw any exception. The system simply couldn’t find the service, even though the service was exported using android:exported="true".
A few shell commands to list, sort or move files in a large folder.
I have a component that writes a log file every time a task is executed, and they all go to the same folder. ls or Midnight Commander take a long time on that folder. I’d like to move the old files out of the way, e.g. to a folder called, well, old. Or I want to delete them. Also, I’d like to list the most recent files, maybe the largest of today, or just the last file that was written. Here a few commands that work on my Ubuntu bash:
A cmake build issue I came across that occurs when building with cmake and the latest version of XCode. The macro find_package(Threads) fails with
-- Looking for pthread.h - not found
Could NOT find Threads (missing: Threads_FOUND)
Digging into the log file tells it is having problems with code signing. What happens is that try_compile() compiles a very small program using pthread, and even this tiny piece needs to be code signed:
Code Signing Error: Code signing is required for product type ‘Application’ in SDK ‘iOS 13.2’
After playing around a bit, I found this workaround: