operating system - OS Pathway Cannot be Found While Using Subprocess

问题描述:

Hello I am having an issue finding the pathway to a folder on a remote pc using os.path.expanduser and subprocess.call. In the code that I have posted below the user name C:\Users\Joe Schmo\ cannot be found, instead the script breaks at C:\Users\Joe I have used the method of placing the path '~/' However, it doesn't seem to be working. I would appreciate any help that could be provided.

#!/usr/bin/env python3

import os

import sys

import gdal

from gdalconst import *

import numpy as np

import math

import subprocess

from subprocess import call

import math

from tkinter import *

import datetime

from tkinter import filedialog

import shutil

#set user so that this script may run remotely

user = os.path.expanduser('~/')

# make dictionary of environmental variables

gdal_env = os.environ.copy()

# modify and add variables

gdal_env["GDAL_DATA"] = "C:\\Program Files\\GDAL\gdal-data"

gdal_env["GDAL_DRIVER_PATH"] = "C:\\Program Files\\GDAL\\gdalplugins"

gdal_env["PATH"] = gdal_env["PATH"] + ";C:\\Program Files\\GDAL"

# Set all of the necessary constants so that the script can create and save the pertinent files