I'm trying to run a remote ssh debugging session in Visual Studio Code. The only problem is the destination system, which is NixOS and i'd like to run a command nix-shell -p python38Full before launching the project.
I know about tasks, I've tried configuring them, but it runs in different terminal, which isn't helpful, because the command above creates shell for executing python environment.
Can I add a line to Python's launch command or execute a command right before launching?
Related
So I am trying to deploy a python Django project on windows server 2012R2. But when trying to run the command I get this error.
When trying to open the link in IIS manager it show error 500.
I am running command prompt as administrator but that did not solve the problem.
Python version:3.8.8
IIS 8
If you need to know version of any other library to answer please comment.
Try to run the wfastcgi-enable.exe in command prompt as system administrator
write "cmd" on windows start, then right click and run the command prompt as administrator. then go to the directory where your python environment install the fastcgi . then run the wfastcgi-enable.exe command
That is how I made it work.
We are using jenkins to run a python script through command prompt. The command is like C:\Program Files\...\someapp.bat test.py. The someapp.bat is a customized python and it has a library called arcpy. The test.py file includes a statement import arcpy.
This command works fine on command prompt on the machine. However, when running through Jenkins, it complains arcpy does not exist. Then I used ssh to access the machine and ran the same command. It has the same error. Then I compared the path in the two command prompts (on machine and ssh), the environments has only one difference which is the Windows. One under user folder and the other under system. But it does not seem to be a dependency of the python bat.
So, in general, what's difference between a remote command line window and a local command line window if logged in as the same user? Any clue is helpful!
I have the VSCode integrated terminal set to my Git bash, using this in settings.json:
"terminal.integrated.automationShell.windows": "${env:LOCALAPPDATA}\\Programs\\Git\\bin\\bash.exe",
I have the Python interpreter selected, using "Python: Select Interpreter" to the interpreter in my virtual environment - when I bring it up, it shows:
Current: C:\work_dir\projdir\py_env\venvdir\Scripts\python.exe
When go to the debugger and start the program (with or without debugging), the bash terminal opens, and this command is issued in the terminal:
/usr/bin/env C:\\work_dir\\projdir\\py_env\\venvdir\\Scripts\\python.exe c:\\Users\\userid\\.vscode\\extensions\\ms-python.python-2020.9.111407\\pythonFiles\\lib\\python\\debugpy\\launcher 61892 -- c:\\work_dir\\projdir\\myscript.py -arg1 arg2
(where the args come from my launch.json)
Then, after the script finishes running, this command is issued in the terminal:
& C:/work_dir/projdir/py_env/venvdir/Scripts/Activate.ps1
Which is the PowerShell way of activating the venv, I guess.
Which, of course, results in:
bash: syntax error near unexpected token `&'
The script actually runs fine.
Why is it that, after running the script in the bash terminal, VSCode issues a command in the terminal to try to activate the venv in a PowerShell way?
This is doubly weird: That it attempts a PowerShell command in a bash terminal, and that it attempts to activate the venv after and not before the script.
The environment is activated automatically after .py file being executed unless you manually change the python.terminal.activateEnvironment setting to false.
More detailed information you can refer to Environments and Terminal Windows
I am having a problem in running a bash command via python and a anaconda environment that the required packages have been installed in the environment. One command acts as server side and start a database and another command should be run in client side in another terminal which has been activated for the same anaconda environment.
How can I run these bash commands separately in a separate terminals in Python?
Is it possible I open client side terminal and activate the anaconda environment, and send the command through os.system() to that specific terminal? If yes, how?
As you can see, in one terminal the following command starts the database:
(my_env) esara#esara-XPS-8920:~/workspace/$ ./command_ -start ./home/db/
and in another terminal I am running the following command:
(my_env) esara#esara-XPS-8920:~/workspace/$ ./command_ -query ./path/to/a file/
How to run these scenario in Python?
I have a python file in which I'm using the subprocess module to execute some command line scripts.
I'm using Git bash to run this python file. In the file, I execute the script:
KG_URL=http://127.0.0.1:8900
This script sets the variable successfully when I run it manually on the git bash command line.
But when I execute this using the python file, it gives me the following error:
'KG_URL' is not recognized as an internal or external command,operable program or batch file.
I tried digging deeper into this and I found out that executing the python file on git bash is the equivalent of running those scripts on the Windows cmd. When I tried running the set command without parameters (to get the current environment variables) on the Windows cmd, I found out that the variable KG_URL does not exist. But when I ran the same command on git bash, I can see that KG_URL exists.
Any idea why this discrepancy exists? And how can I solve this issue?
The reason why I'm executing these scripts in a Python file is because I need to convert it into an exe later. Assuming that all environments where I run this exe will have git bash installed, is there any way of ensuring that these scripts run only through git bash, and not the Windows cmd?