Path to Powershell.exe (v 2.0)

I believe it’s in C:\Windows\System32\WindowsPowershell\v1.0\. In order to confuse the innocent, MS kept it in a directory labeled “v1.0”. Running this on Windows 7 and checking the version number via $Host.Version (Determine installed PowerShell version) shows it’s 2.0. Another option is type $PSVersionTable at the command prompt. If you are running v2.0, the output will … Read more

Access to the path is denied when saving image

Access to the path ‘C:\inetpub\wwwroot\mysite\images\savehere’ is denied Read the message carefully. You are trying to save to a file that has the same name as the directory. That cannot work, you can’t overwrite a directory filled with files with a single new file. That would cause undiagnosable data loss, “Access to the path is denied” … Read more

How should I write a Windows path in a Python string literal?

you can use always: ‘C:/mydir’ this works both in linux and windows. Other posibility is ‘C:\\mydir’ if you have problems with some names you can also try raw string literals: r’C:\mydir’ however best practice is to use the os.path module functions that always select the correct configuration for your OS: os.path.join(mydir, myfile) From python 3.4 … Read more

Error “‘git’ is not recognized as an internal or external command”

You may not have set your PATH correctly to point at your Git installation. You need to add the following paths to PATH: C:\Program Files\Git\bin\ C:\Program Files\Git\cmd\ And check that these paths are correct. You may have Git installed on a different drive, or under Program Files (x86). Correct the paths if necessary. Modifying PATH … Read more

How to use to find files recursively?

There are a couple of ways: pathlib.Path().rglob() Use pathlib.Path().rglob() from the pathlib module, which was introduced in Python 3.5. from pathlib import Path for path in Path(‘src’).rglob(‘*.c’): print(path.name) glob.glob() If you don’t want to use pathlib, use glob.glob(): from glob import glob for filename in glob(‘src/**/*.c’, recursive=True): print(filename) For cases where matching files beginning with … Read more

How do I create a directory, and any missing parent directories?

On Python ≥ 3.5, use pathlib.Path.mkdir: from pathlib import Path Path(“/my/directory”).mkdir(parents=True, exist_ok=True) For older versions of Python, I see two answers with good qualities, each with a small flaw, so I will give my take on it: Try os.path.exists, and consider os.makedirs for the creation. import os if not os.path.exists(directory): os.makedirs(directory) As noted in comments … Read more

How can I get the application base path from a module in Node.js?

The approach of using __dirname is the most reliable one. It will always give you correct directory. You do not have to worry about ../../ in Windows environment as path.join() will take care of that. There is an alternative solution though. You can use process.cwd() which returns the current working directory of the process. That … Read more

How to update system PATH variable permanently from cmd?

Type setx /? to get basic command help. You’ll easily discover: /M Specifies that the variable should be set in the system wide (HKEY_LOCAL_MACHINE) environment. The default is to set the variable under the HKEY_CURRENT_USER environment. You need to run this from an elevated command prompt. Right-click the cmd shortcut and select Run as Administrator. … Read more