Python command line not accepting tabs - python

(I don't know if this is an appropriate question for StackOverflow, as it's about a tool rather than a language.)
My Python 3.3.1 (32-bit) command line ("C:\Python33\python.exe") has stopped accepting tab characters. It can print them, but pressing the Tab key just makes the cursor blink at me (it reacts, but doesn't move). It wasn't happening earlier today.
I also have 2.7 (32-bit) and 3.2 (64-bit) installed, and neither of them have this problem. Trying to run each of the python.exe executables from the same cmd.exe window gives the same result, so it's not due to the command line window settings. Running a .py file (">python my.py") doesn't have the problem. IDLE for 3.3 doesn't have the problem.
Also, when pasting text from the clipboard, they're read s l o w l y (takes about 15 seconds to read a hundred lines of 50-char commented lines, compared to less than a second on the others) and
The only change I remember making recently (since the last time I remember opening python.exe) was to install Scipy for 3.3 from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy-stack (32-bit).
No, I have not tried turning the computer off and on again. I hope not to. I haven't tried uninstalling and reinstalling Python 3.3, since that means reinstalling packages. Updating to 3.3.3 didn't solve the problem.

Try to remove the pyreadline directory in lib\site-packages. Scipy-stack includes pyreadline, which is required for the IPython terminal but also changes the behavior of the standard interactive prompt.

Related

Python fails silently

I am trying to get started with Python, so I installed Python 3.8, from python.org (on Windows 10). I remembered to check the "Add to PATH" during the installation and I have confirmed that it has been added to path, as seen in the first image.
However, when I try to use any commands, whether it be python --version or python HelloWorld.py, nothing happens. I have tried both the traditional command line as well as Powershell. I have also tried replacing python with python3, the result is the same. As you can see in the second image, I get no errors, just a blank line. So it's not that it cannot find Python at all, it rather seems that something is wrong with the installation.
Have anyone else encountered this kind of behavior? I have tried re-installing Python as well as removing old installations.
Image 1: Python seems to be correctly added to PATH.
Image 2: Python fails to return any output. But also no error. Same thing happens with python HelloWorld.py.
Update 1 - Here is what I have tried so far:
Changing PATH to refer directly to exe file.
Using both Command Prompt and PowerShell.
Rebooting the PC.
Re-installing Python (including removing old versions).
Both the python and python3 command.
Update 2 - NameError: name 'python' is not defined
Update on the update: This was a wild goose chase. You are not supposed to be able to use that command in the interpreter, as described in this post.
So I tried to use the console from the python.exe file instead, and I got the following answer. However, from what I can find on it, it's normally a problem you encounter on elements of the code (like print()) and not on the python command...?
(image removed)
Update 3 - It works (kinda)
If I use the command py --version or py test.py it works. I have no clue why though...
After extensive research, I still cannot find an answer to my own question. But I have found a work around, which minimizes the consequences:
Instead of using python, simply use py.
This will invoke the Python launcher instead of Python itself (from what I've read). For most people this will be good enough, but it is not the same. So it might cause issues and version mismatch in certain scenarios.
Also, despite of this weird behavior, Python seems to run fine in Visual Studio Code, when using the "Run" button (or the py command in the terminal).

Blank python IDLE window when opening python file on macOS

For some reason, whenever I try to open a python script that has around ~450 lines of code, IDLE's windows simply appears empty and when I try to run it doesn't run anything either... However, if I try to run a smaller program it works for some reason. Does anybody know how I am able to run a python script on my Mac besides IDLE or how to fix the IDLE window being blank whenever I open a file?
To learn how to run Python Python programs on a Mac, read Chapters 1 and 4 of Python Setup and Usage. Running from an IDLE editor is just one way.
IDLE uses the tkinter module which wraps the tcl/tk GUI framework. Did you read and follow the instructions of how to replace the buggy tcl/tk that Apple supplies? Read the entire page before starting! Ignoring this page is the most common reason people have problems with IDLE on the Mac. There are a few others, but I do not remember one that matches your description.

Using Anaconda Python, esp. ipython, in cygwin, esp. emacs

I am working on a good Python environment for use on a Windows 7 machine. I am a big emacs fan, and like using the windows native build that's part of cygwin (emacs-w32). This way, I have access to all the cygwin tools from within emacs.
I also really like Anaconda's python distribution. I really don't feature downloading and maintaining all those packages myself, esp. within cygwin.
Also a big ipython fan.
On a Linux cluster, I'm having good luck using ipython as my python interpeter within emacs. I make a lot of plots, so matplotlib has to work too.
So I'm trying to get "ipython interpeter within cygwin emacs" to work.
Is this a good idea? Better ways to go? I know there's Spyder, but I honestly like working within emacs for editing .py files. Not just emacs keybindings - the whole emacs environment (grep, ediff, dired, etc etc).
Right now, I've gotten emacs to pick up ipython in the python 3 anaconda install. It runs, but I get extransous characters, e.g.:
^A^BIn [^A^B1^A^B]: ^A^B
instead of In [ 1 ]:
Also figure windows tend to not work (figure appears, but Windows says Not Responding, plots don't appear).
Thanks.
Update:
Thanks for the response. I did some more playing. To be exact:
* Setup bash path so Anaconda python and ipython found
* Started ConEmu (windows terminal program)
* ran bash from a cmd (dos) prompt
* ran cygwin's emacs: emacs -nw -Q (no window and no customization)
* Open .py file, C-c C-z, runs Anaconda python -i
* Get these messages:
Make dedicated process? (y or n) n
Making python-shell-interpreter local to Python while let-bound!
Making python-shell-interpreter-args local to Python while let-bound!
funcall: Args out of range: "^M", 0, 2
The final line appears in the emacs "status line" at the bottom. There is a buffer with Python running, seems to be fine. Except Ctrl-D doesn't work. If I type 'quit', I get the message "Use quit() or Ctrl-Z plus Return to exit." What happened to Ctrl-D?
If I repeat the exercise with ipython, the same messages are given, ipython buffer runs, I get the random ^A^B's, Ctrl-D doesn't work.

What is the difference between running python in terminal and in IDE?

I'm new in Python. I'm using Windows 7.
When I install pip on my computer, I need to use the installing program: get-pip.py.
I found 3 ways to run this .py file:
In cmd, type "python get-pip.py"
Open it with IDLE and F5
Double click get-pip.py
I have two questions:
The only way can install it is "1. In cmd, type "python get-pip.py". I wonder what's the difference between 1 2 and 3?
Usually, when I double click .py file, it is usually opened by idle(default). But this time, when I double click get-pip.py, it begins running as if a .exe file. Why?
Thank you.
Answer to question 1.
If you run python from within a command window (cmd) you will be able to see the output if any. As opposed to double clicking it which will run the program and close it unless the program is supposed to do otherwise. And Idle is mimicking the open command window.
One thing to watch out for is having 2 python interpreters on the system. If you are just starting out I would avoid installing a 2nd one. Removing old python interpreters is as easy as removing the folder they are in. You said it "runs differently" which makes me think this is a concern.
Answer to question 2
You can change what program uses the file. You can have idle read it, or the python interpreter run it. check out http://www.thewindowsclub.com/change-file-associations-windows for info on how to change that behavior.

wx.App (wxPython) crash when calling

Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here.
with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False)
Then the interpreter crashed with Windows error reporting.
I tried both python 2.7.1 and 2.6.6 with wxPython 2.8.11, all come from their main website, still no luck.
Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App
If you are running that in IDLE, then that is your problem. IDLE and wx don't get along very well because you basically end up with two mainloops fighting each other. Try putting it in a file and then run the file from the command line:
c:\python27\python.exe myPyFile.py
That should work just fine. Otherwise, download the correct wxPython for your Python and OS (32/64 bit), uninstall the current one and install the new one. I've been using wxPython on Windows XP, Vista and 7 with no problems like this.
In case like me somebody will stumble into this question like I did. Recently installed wxpython on two machines, windows 7 and XP. Testing the sample code in simple.py (provided with the wxpython docs-demos installer), running from a python console, I had the following problem on both machines: First import ok, but when I did a reload of the module, python crash.
I added this line in the end of the simple.py file: del app
and that fixed the problem on windows 7 and tomorrow I try it on the XP machine.
Same solution fitted for the XP machine. So, reloading an un-edited module with a reference to a wx.App with a closed gui seem not to be feasable. Killing the reference with a del statement was enough to solve the problem.
I searched for a while and found that this is the problem with wxPython and Python >2.5. Tried many fix with manyfest file but no luck, so I think switch to PyQt is the only solution now.

Categories