Python3.6 on Windows MINGW64 console doesn't run the interpreter [duplicate] - python

This question already has answers here:
Python not working in the command line of git bash
(20 answers)
Closed 5 years ago.
I'm experiencing the same issue as this question with Python 3.6. It works well under the Windows console, but it fails to launch or work under MINGW64. Even when I use the direct path of /c/Python36/python.exe, nothing happens. I don't get the interactive REPL with the usual Python interpreter version and >>> prompt, as I do in the Windows console.
Any pointers on how to debug this?

Ah - further search yielded this stackoverflow question that contained the answer - use python -i

Related

SyntaxError when pasting multiple lines in Python [duplicate]

This question already has an answer here:
Pasting multiple lines in MacOs Python shell returns SyntaxError
(1 answer)
Closed 1 year ago.
I'm having trouble copy-pasting code in Python. Say I have the following code I want to paste into a Python interpreter:
string_one = "Help"
string_two = "Me"
Locally, running 3.8.5 on a Mac OSX 10.15.7, if I paste that code, I get SyntaxError: multiple statements found while compiling a single statement.
However, if I ssh into another machine, open up Python (3.7.4), and paste those two lines, I get no error. Also, when I paste those two lines into a Python 2.7.16 shell, I get no error. What could possibly be the problem here?
Python 3 (problem shell)
Python 2 (non-problem shell)
It seems that there is a bug in readline (which is used by Homebrew to install python)
Short answer:
echo "set enable-bracketed-paste off" >> ~/.inputrc
Long answer:
https://github.com/Homebrew/homebrew-core/issues/68193
(This was erroneously edited into the question; I have rolled back that edit, and am pasting the solution as an actual answer instead, and tagging as Community Wiki.)

run setenv linux command in python script [duplicate]

This question already has answers here:
How to set environment variables in Python?
(19 answers)
Running 'export' command with Pythons 'subprocess' does not work
(1 answer)
Closed 2 years ago.
I want to run setenv command through python script, the linux command is as below
setenv MODEL path/to/the/model
I tried using os.environ(), but I couldn't get the right syntax.
note - I'm using python 2.7
os.environ isn't a function. Check out the docs: https://docs.python.org/2/library/os.html#os.environ
This question may also be helpful to you: How to set environment variables in Python. If it is, pay attention to the comments on the top answer.

VS Code - can you display a Python shell [duplicate]

This question already has answers here:
How to execute Python code from within Visual Studio Code
(34 answers)
Closed 4 years ago.
When using Python IDLE I find the Python shell, with the >>> prompt very useful for testing syntax. Is there a way of getting a Python shell integrated in VS Code?
Maybe the answer is just to open Python IDLE in another window.
Apparently this is a duplicate of another question, but I did several searches on the words Python shell and didn't find anything that seemed relevant. Sorry.
Many thanks to Jaxi for the answer that you need to type Python in the Terminal Window.
stated here you can use ctrl+backtick to open a terminal window, then from there just type python and it will give you the python shell:
https://code.visualstudio.com/docs/editor/integrated-terminal

How can I run a python script in ubuntu background? [duplicate]

This question already has answers here:
How to run a script in the background even after I logout SSH?
(12 answers)
Closed 5 years ago.
How can I run a python script in ubuntu background? I tried to use '&', for example:
python3 test.py &
but when I close the terminal, this process seems to be closed as well because I can't get any update logs from this test script any more.
You can use setsid. In your case by running:
setsid python test.py
Or, as mentioned in the comments, you can use nohup.
nohup python test.py
You can see the difference between them in this answer: What's the difference between nohup and a daemon?
I think you're looking for the nohup command as Serge mentioned.
This answer looks like what you want

How can I open Python3.3 IDLE from command line on windows? [duplicate]

This question already has answers here:
starting Python IDLE from command line to edit scripts
(8 answers)
Closed 8 years ago.
I am trying to do like this answer to the "same" question. But doesn't work.
How can I open Python3.3 IDLE from command line on windows?
You need to do as stated in the main.py file of the idelib folder (C:\Python33\Lib\idlelib)
IDLE main entry point
Run IDLE as python -m idlelib
So with python -m idlelib <script_to_edit> you will be able to open and edit the script with idle.
I haven't checked with previous versions but it could have the same usage.

Categories

Resources