powershell

PowerShell setting environment variable to subexpression discards newline

PowerShell setting environment variable to subexpression discards newline Question: I have a python script: # temp.py print("foonbar") I can run this in powershell: > python .temp.py foo bar I want to set the environment variable FOO to the output of this python script. However, doing so changes the newline to a space: > $env:FOO=$(python .temp.py) …

Total answers: 1

Powershell Filepath command is being altered by Pycharm

Powershell Filepath command is being altered by Pycharm Question: I’m trying to run a file path powershell command through python. ` import subprocess subprocess.call(‘powershell.exe cd OneDriveDesktopOpenPoseopenpose-1.7.0-binaries-win64-gpu-python3.7-flir-3d_recommended’, shell=True) ` The error message displays: Cannot find path ‘C:UserscubeowOneDriveDesktopOpenPoseImplementationOneDriveDesktopOpenPoseopenpose-1.7.0-binarie s-win64-gpu-python3.7-flir-3d_recommended’ because it does not exist. The error message showed that they had added a root path in front …

Total answers: 1

Opening powershell from python

Opening powershell from python Question: I would like to open a powershell from my python script, then launch another python script in this newly created powershell. import subprocess subprocess.call("start C:\Windows\System32\WindowsPowerShell\v1.0", shell=True) # Here, I would like to write this in the new opened powershell : python ./hello_world.py (then press ENTER) input("end") Any idea how I …

Total answers: 3

Python vs Powershell for collapsing long directory path into short

Python vs Powershell for collapsing long directory path into short Question: Recently, I downloaded a large online dataset (approx. 12 Terabytes size) and it has dummy intermediate folders as shown in the left-side of the following figure. I want to remove (collapse) all intermediate folders as in the right-side of the figure below: Method 1) …

Total answers: 1

Cannot make Virtual Envoirment

Cannot make Virtual Envoirment Question: I have been following all the steps VSC’s tutorial ia giving me but i keep running into this error py : The term ‘py’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was …

Total answers: 1

Powershell appears after converting program to exe

Powershell appears after converting program to exe Question: I’ve got a program that I converted to an exe using auto-py-to-exe and pyinstaller. The problem is that some commands require powershell, and whenever I use powershell it pops up despite me hiding the console. I run the command like this: command = [POWERSHELL_PATH, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘echo …

Total answers: 2

ModuleNotFoundError: No module named 'requests' error for docker run

ModuleNotFoundError: No module named 'requests' error for docker run Question: I have created the docker image to run python script. Now when I run below command it throwing error. command in powershell: docker build -t pull_request_summary . Error: Traceback (most recent call last): File "/usr/app/src/./listPullRequest.py", line 1, in import requests ModuleNotFoundError: No module named ‘requests’ …

Total answers: 1

Capturing output from Powershell command and saving it in a variable

Capturing output from Powershell command and saving it in a variable Question: I keep trying to run this piece of code but everytime I print, it seems to net me nothing in regards to what I see with my output. p = subprocess.run(["powershell.exe", "C://Users//xxxxx//Documents//betterNetstatOut.ps1"], shell=True, capture_output=True, text=True) output = p.stdout print(output) My PowerShell command is …

Total answers: 2