When I run a program from a USB memory, and remove the USB memory the program still goes on running (I mean with out really copying the program into the Windows PC).
However, does the program make its copy inside the Windows in any hidden location or temporary folder while running by the python IDLE. From where the python IDLE receive the code to be running after removing the USB memory? I am going to run python program in a public shared PC so I do not want anyone find out my code, I just want to run it, and get the result next day. Does someone can get my code even I remove the USB memory?
There are plenty of ways someone can get your program, even if you remove the USB drive.
They can install a program that triggers when a USB stick is inserted, search the stick for .py files, and copies them to disk.
If the Python installation you're using is on the disk instead of the USB drive, they can replace the Python executable with a wrapper that saves copies of any file the Python interpreter opens.
Your program is going to go into RAM, and depending on what it does and what else is using the machine, it may get swapped to disk. An attacker may be able to read your program out of RAM or reconstruct it from the swap file.
It sounds like you are doing something you probably shouldn't be doing. Depending on how much people want your code they could go as far as physically freezing the ram and doing a forensic IT analysis. In short, you can't prevent code cloning on a machine you don't administer.
Related
I have a short script written in python that saves a simple .txt to the same directory the .py file is in. Problem is: It only does so on one of my two computers.
My code doesn't include a hard-coded path to write to. On my laptop, I can put the makemeanote.py in any folder and it will create the note right there. On my desktop pc, all the notes end up in System32. PATH is set exactly the same way on both machines, and both use Windows\py.exe as the executable.
Somewhat interestingly, I only get an admin-screen on the desktop pc, asking if I want to allow changes to my system by "Built: Release_master_v3.8.2_"etc., whereas on my laptop it simply runs and does its job.
No amount of un- and reinstalling has changed anything, even when I thought I had eradicated any trace of python on my hard drive. Both PCs use current Win10/64 installations.
What is happening there?
A clarification: It's not about fixing the bug, it's about understanding the inconsistent behaviour! I know I could just hard-code any directory, but that takes away the beauty, don't you think?
I finally found the cause of the weird behavior:
For some reason, the py.exe in my WINDOWS folder was set to always be run as admin. As soon as I unchecked that option, the User Account Control (UAC) check disappeared and my file finally behaved as I had expected.
I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3
My problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new/'Untitled.py' file, the save folder will pop open, and I can name the new file/navigate folders, but once I hit "Save", the program freezes with the save folder still open, except now the Save/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.
What's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.
To be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up.
I had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.
Please help!
I've also had this problem, and what I did was change the location of where the file would save. I suggest trying this to help.
I'd suggest reinstalling python idle (your programs will be saved). If this doesn't work then maybe it has something to do with your security on the mac.
I had the same problem, and as Aadi suggested, I was able to fix it by changing the location of where the file was saved. Possibly, this relates to very long paths, at least in Windows 10.
The path that didn't work was 114 characters long. The path that did work was 93 characters long. The paths are the same up to character 80 and use underscore (_) but no unusual characters.
You don't have to make/save python files in IDLE. You can open any text editor, type the code, and save as name.py. Then you can open that in IDLE. I would use that for now.
I also came across with same issue, this is only issue of currupt file,please delete recent python IDLE file that you have created,this will definately work
I am trying to find ways to make better use of my time while programming.
I have a python script that does some heavy work (it can take hours) to finish. Now, most of the work it does is network related, so i have plenty of cpu resources to spare.
If the script was a C binary executable, it would be fine to git checkout onto a different branch and do extra work, I could even modify the binary in disk as it has been copied to ram, so until it finishes running I won't affect program output.
But python scripts are translated, not compiled. What happens if I start tampering with the source file, can i corrupt the programs output, or is the text file and associated imports copied to RAM, allowing me to tamper with the source with no risk of changing the behaviour of the running program?
In general, if you have a single Python file which you run as a script, you're fine. When you run the file, it is compiled into bytecode which is then executed. You can change the original script at this point and nothing breaks.
However, we can deliberately break it by writing some horrible but legal code like this:
horrible.py:
from time import sleep
sleep(10)
import silly
silly.thing()
silly.py:
def thing():
print("Wow!")
You can run horrible.py and while it is running you can edit silly.py on disk to make it do something else. When silly.py is finally imported, the updated version will be loaded.
A workaround is to put all your imports at the top of the file, which you probably do anyway.
When a python program is run it is compiled (kinda, more like translated) into a .pyc file that is then run by the python interpreter. When you change a file it should NOT affect the code if it is already running.
Here is a related stackoverflow answer. What will happen if I modify a Python script while it's running?
Why not have another working directory where you make your modifications? Is there a lot of ancillary data or something that makes it hard to set up a working directory? I.e. if your working directory is A, git clone A B, and then work in B. When you're done, you can pull the changes back from B to A:
git remote add B ../B
git pull B master
I am having a problem with PyCharm (Community Edition) in that, when I open a .py file in the program, I can happily read and write in the file as usual, however when I click out of PyCharm (to look my emails for example) and then click back into it to carry on with my code, the file automatically closes and the project tree structure collapses (so I have to re-open it every time).
So far I have tried changing the tab limit to a high number, but this doesn't seem to help (and it shouldn't be related, since this happens when I open just one file).
I had the same issue before. I'm assuming you're connected to a network shared folder via UNC path (e.g. \\foo\bar\)?
If so, it is not currently supported. You'll need to map your network folder and give it a Drive letter. Then load up your project using the mapped drive, and it'll work like a charm.
If that's not the scenario though, please give us more information.
EDIT2: Stress tested the fix, it still failed after creating near 1TB of intermediary files. Changed .py code to delete intermediary files after performing necessary processes. Stress test succeeded after this change. Original issues likely to do with memory. Still no way of proving.
EDIT: I'm still not sure whether or not it was a memory issue. However I got the full process to run via .bat by breaking up the second script into 4 additional .py files and running those instead of the full second script at once. Problem solved for now.
ORIGINAL:
I am running two .py files through cmd via a .bat file. The reason I am doing this is the first .py is an arcpy file that requires use of 32 bit python, and the second .py is a combined PCI and arcpy file that requires use of 64 bit python.
The first file runs without issue. The second file gets to a certain point, the same point every time, and I am prompted with a "python.exe has stopped working" dialog box. This point is in the middle of a for loop in the PCI section of code. I have run the PCI python in PCI's interpreter without issue. I suspect this might be related to memory issues but am uncertain, and have no idea how to check.
How do I check to see if memory issues are the problem?
.bat code below:
C:/Python27/ArcGIS10.5/python.exe E:/Path/CODE/file1.py
C:/Python27/ArcGISx6410.5/python.exe E:/Path/CODE/file2.py