I am missing something really obvious here... but when I run this program
python gregs_program.py
it will work fine.... but if I make changes and then save it, I go to run
python gregs_program.py
and it runs the old version (doesn't update my changes)! I notice I have both
"gregs_program.py" and
"gregs_program.py~" when I do the 'ls' command in Terminal.
What am I missing here?
The problem could only be a few things (all of which I have done before):
The editing window is not in the same place (directory/computer) as the run window.
There was an error writing the updated copy, maybe from a readonly filesystem, out of space, etc.
The editor is in some weird mode and did not receive a command to write.
Related
I tried to run a python program in VS Code. But my program didn't run. The terminal opened and a weird arrow was there in the terminal. This is the screenshot of that.
This is the weird arrow and the program is not running. Any ideas why this is happening and how to fix it?
Thanks in advance.
Firstly, the arrows are included in the default python IDE means that VScode ran the command to execute your code. Give your pc a restart. Now, let us check if python is working or not or VS code is having some trouble. Type the following command in cmd to execute the code-
python "$PATH"
Rember to replace $PATH to the path of the file i.e where your file is stored. For eg. I've my python files stored in D drive in a python folder, so I'll use-
python "D:\Python\Hello.py"
If this works, python is working fine and if not, try reinstalling python and check the box which says Add python to Path or Environment variables. Then open VS code try to run the program again. But click the button only once and be patient because clicking it multiple times causes execute the same command again and cause a problem. It's my personal experience. Wait 5 minutes. Not works. Don't worry, there's a problem with the run extension you are using. I'll recommend the Code runner by Jun han. I personally use it. Type this in the extension search box-
formulahendry.code-runner
Install it and then try again.
Kill the terminal, and retry. If not work, restart the VSCode.
something weird is going on. I have created a program with PyQt that when opened in Spyder works flawlessly. However if I create the installer with Pyinstall and run it, the program opens normally but once I click on a cell of a table from the main window, it crashes (so I think it has to do with the mousePressEvent() method?
Is there a way where I can debug it, or know where the error is exactly? Because when it crashes the only thing I get is a message of 'Python has stopped working'.
I do have some try blocks around the code and as I said, when opened from the IDE the whole program works as expected.
Please let me know if you need more info
Thanks
EDIT: For a bit more context, if I put the whole mousePressEvent() method in a try block it will still crash when I click the on a cell of the table
Have you include your external resource (like a image) in PyInstaller with the right path folder ? like in this link and have adapt your code ? https://pythonhosted.org/PyInstaller/spec-files.html#adding-data-files ?
I am brand new to Python, and tried downloading Python on my computer but had some issues because I have a very old Macbook that can only run OSX 10.6. I have been trying to use Python Anywhere, but I cant seem to edit the code I write in the console. For example, if I write a bunch of code and then run it and get an parentheses error, I have to re-enter all of that code onto the next command line and add the parentheses rather than just adding the parentheses to the code and re-running it. I can just copy and paste the bad code onto the new line, fix the error, and then re-run the code, but this gets tedious. Sorry if this is a dumb question, but I have used R a bit before and in R you can simply edit the code, then run it again, so I am wondering if there is a way to write Python code in this same manner.
There's two main ways of entering code into PythonAnywhere:
the first is to type it interactively into a live interpreter or "Console". You do that from the PythonAnywhere "Consoles" tab. it sounds like that's what you've done so far
the second is to create a file. You do that via the "Files" tab. if you create a new file with a .py ending (eg hello.py) PythonAnywhere will bring up an editor which you can use to save a file, and then you can run it, see the output below the editor, then make changes, re-run, etc.
So I have uTorrent set up to run a Python script when a torrent's state is changed so it can sort it. It all works fine except it takes focus from whatever I'm doing and it's crazy annoying.
I run it using sorter.py <arguments>. I'm on Windows 10. What can I do, if anything, to get this to run in the background and not take focus from what I'm doing?
I'm also sorry if this has already been answered but I couldn't find anything that worked.
Running with pythonw (or changing extension to .pyw which is the same) may help.
pythonw.exe doesn't create a console window but I dunno about focus. It doesn't create any windows by default, either, so it shouldn't steal it.
EDIT: The code I wrote in my Python file was just this:
print "foo"
I'm using Windows XP Home Premium on this tiny little HP Mini 1000, and I want to run Python files, since we're learning it in school. I am aware of this topic, so I tried to run Python files using a batch file (python.bat), and I'm getting an error that says, "Can't find 'main' module in ''" whenever I run the batch file. I followed the instructions given here. All I did was change "Python26" to "Python33" because of the difference in versions.
Any idea what's wrong here? I really want to run Python files from Notepad++, so I don't want any alternative ways to run them.
This sounds like you don't have PYTHONPATH set up correctly. I suggest you review the documentation here:
http://docs.python.org/2/using/windows.html
Instead of calling Python, call cmd.exe and then use the set command to inspect which variables are set and how they are set. Run the exit command to leave the command shell. When you think you have the variables set up correctly, try again to run Python.
Good luck and have fun!
I use the command line interpreter or IDLE mostly (Win 8.1 now, but I've done so since Win XP SP2), but NPP is my main text editor, so I was curious about this issue.
When I was reproducing this, I was able to generate several errors, but the only one I got that was an exact match was when I failed to configure the Run option correctly.
You need to make sure to follow this step exactly in the instructions you were following. When you navigate to Run -> Run in Notepad++, you have to enter this exactly:
C:\Python33\python.bat "$(FULL_CURRENT_PATH)"
I am pretty sure you left out the "$(FULL_CURRENT_PATH)", or otherwise didn't add it correctly, as failing to do so causes exactly the same error on my end. Failing to include this means that when you run the batch script, you get the wrong input to the Python interpreter, causing the error.