Skip to main content

os.environ['SSL_CERT_FILE'] stores a path to a non-existing file in visual studio code while debugging

This question is directly connected to my last question, however tackles a different topic so I am opening a new one.

As mentioned there I am getting an error relating to a missing SSL cert. The error does not appear when the script is started from Terminal, using PyCharm or running from VSCode, but without the debugger. Only when the script is run with the debugger, the exception is thrown.

After debugging a while I have found that the reason for the problem is the environment variable os.environ['SSL_CERT_FILE'] which in this case leads to a non-existing C:\\Users\\MYUSER~1\\AppData\\Local\\Temp\\_MEI97082\\certifi\\cacert.pem

  1. Starting the script without the debugger or in PyCharm, this variable is not set (debugging the imported minio package showed me that the result of certifi.where() is used if the variable is empty.
  2. With the debugger on, it is set before any of my script is executed (import os and print out all environment variables in the first line)
  3. If I manually delete the variable with del os.environ['SSL_CERT_FILE'] the rest of the script works fine, but the variable is again set in the next run
  4. I am using python 3.11, MiniConda and Windows 10, Visual Studio Code is updated to the last version 1.77.0
  5. Setting the environment variable in launch.json with "env": {"SSL_CERT_FILE": "foo"} will override the varible as expected, however as soon as I remove this line the wrong value appears again.
  6. The part "..\\_MEI247522\\..." in the value will change from run to run
  7. Creating a completely new folder/project the problem still exists
  8. I also tested with another python environment (Python 3.9.7) and the problem still is the same.
  9. From user @Horsing's suggestion: I have also removed all the code from my script, except for import os. As soon as os is imported and I can inspect os.environ, the environment variable is already set.

I honestly have no idea, where and why this variable is set when the script is run in the debugger and what triggers it. Any help would be much appreciated, since manually deleting it is not really a good solution!

Addition Here is the Python Debug Console output in VS Code (with my username changed). For this I have removed the launch.json and started the debugger with Python:File

complete code:

import os
print(os.environ.get('SSL_CERT_FILE'))

console output:

(minio) PS C:\Users\myuser\Documents\source\Python\minio-project>  c:; cd 'c:\Users\myuser\Documents\source\Python\minio-project'; & 'C:\Users\myuser\Miniconda3\envs\minio\python.exe' 'c:\Users\myuser\.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '60007' '--' 'C:\Users\myuser\Documents\source\Python\minio-project\main.py' 
C:\Users\MYUSER~1\AppData\Local\Temp\_MEI223042\certifi\cacert.pem

Again, the printed path does not exist on my computer



source https://stackoverflow.com/questions/75926017/os-environssl-cert-file-stores-a-path-to-a-non-existing-file-in-visual-studi

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype