Python Forum
Absolute paths in subprocess - file not found
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Absolute paths in subprocess - file not found
#1
I've tried every permutation I can think of to get rid of this message - eg variables, literals, back slashes, forward slashes etc etc (thinking that was the issue) - But looking at the error on the internet, it maybe something more environment related, which I don't understand - If anyone has the answer, please could you post it in beginner speak!

NB - Database exists - C:/Users/gonks/Desktop/python_work/db/VE_match
table exists in it - db_val_policy
input CSV exits - C:/Users/gonks/Desktop/python_work/csv_val_pol.csv

from pathlib import Path
import sqlite3
import subprocess
import csv

#csv_file = Path("C:/Users/gonks/Desktop/python_work/csv_val_pol.csv")
#db_name = Path("C:/Users/gonks/Desktop/python_work/db/VE_match")
csv_file = Path("C:\\Users\\gonks\\Desktop\\python_work\\csv_val_pol.csv")
db_name = Path("C:\\Users\\gonks\\Desktop\\python_work\\db\\VE_match")

result = subprocess.run(['sqlite3',
                         "C:\\Users\\gonks\\Desktop\\python_work\\db\\VE_match".replace('\\','\\\\'),
                         '-cmd',
                         '.mode csv',
                         '.import --skip 1 C:\\Users\\gonks\\Desktop\\python_work\\db\\VE_match'.replace('\\','\\\\'), 'db_val_policy'],
                        capture_output=True)
Error:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified PS C:\Users\gonks>
Reply


Messages In This Thread
Absolute paths in subprocess - file not found - by kittyticker - Jan-28-2024, 05:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  file open "file not found error" shanoger 8 1,364 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 840 Oct-29-2023, 12:40 PM
Last Post: Mark17
  File not found error saisankalpj 10 4,077 Jul-04-2022, 07:57 AM
Last Post: saisankalpj
  pdf2image, poppler and paths jehoshua 18 15,550 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,541 May-29-2022, 09:11 AM
Last Post: snippsat
  How to run a particular file in subprocess Shiri 5 1,835 Nov-24-2021, 09:29 AM
Last Post: ghoul
  Subprocess.Popen() not working when reading file path from csv file herwin 13 15,559 May-07-2021, 03:26 PM
Last Post: herwin
  automatically get absolute paths oclmedyb 1 2,175 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,611 Nov-23-2020, 05:15 PM
Last Post: cananb
  subprocess call cannot find the file specified RRR 6 16,968 Oct-15-2020, 11:29 AM
Last Post: RRR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020