I am using Notepad++ as an editor and I am running Python 3 from Notepad. This is the code:
import sys
def write():
print ("Creating new file")
name = 'NewFile.txt'
file = open(name,'w')
file.close()
write()
The problem is not the code itself, I think. When I run the code from Windows PowerShell like this: python code.py
, it works fine and creates the file, but this is creating the file using Python 2.7. I need to use Python 3.
When I run Python 3 from Notepad++ the file won't be created.
I tried running Python 2.7 from Notepad++ but it just doesn't work. I run it like this:
C:\Python27\python.exe -i "$(FULL_CURRENT_PATH)"
or with Python 3 I run it like this:
C:\Python35\python.exe -i "$(FULL_CURRENT_PATH)" .
I also run Notepad++ as administrator.
I think I could solve this by running Python 3 alongside Python 2 in PowerShell, but I don't know how and the answers to these questions do not work for me:
I am open to changing my editor (Notepad++) or any solutions really.
So, how can I make Notepad++ create a new file? Or How can I make Python 3 run in PowerShell? Or Which editor could I use to fix this? Or maybe my code is just wrong.
Edit: When I say it doesn't work I mean that the file will not be created even tough my code runs (no error msg).
To be clear, what you're describing seems to be: a) when you run your file manually from the command prompt, it gives the expected results; b) when you run it instead through Notepad++, you don't see any evidence that it runs at all. Is that right?.
Yes, that's right. I'm also not sure what is the interactive interpreter.