Python newbie here. Am using Anaconda (on Windows 7) by recommendation of a friend.
What I want to be able to do is make a change to my class in Notepad++ and then test it in my Python command prompt window immediately.
This is a simple question that I can't seem to find the answer: in what directory does a default installation of Anaconda expect me to be storing my .py files (so that I can easily load them using import <MODULE NAME>
)?
My PATH variable is set to:
C:\USERS\<USERNAME>\Anaconda3;C:\USERS\<USERNAME>\Anaconda3\Scripts
(this is the default)
Am I supposed to be working out of the Scripts
directory...? There's already a lot of files in there.
What do most people do? Perhaps add another folder to the PATH variable and work out of there? Do you add a new folder to PATH for each project or is there a way that makes more sense? I already have a Projects directory I use for everything else. I'd like to just be able to work out of there.
I am coding in Notepad++. I don't really want to bother setting up/learning an IDE (I'm just doing relatively simple I/O file manipulation that I have previously been doing in Excel... the horror).
Sorry for the extremely newbie question. I searched and could not find anything relevant.
EDIT AFTER ACCEPTED ANSWER:
The problem was that I was running python.exe from the Start menu. I did not realize that you are supposed to open a CMD window in the folder (SHIFT+RIGHT CLICK) you are working in (such as C:\USERS\<USERNAME>\MY PYTHON STUFF
) and run python from there.
This might be what you're attempting. Note that I also use Anaconda.
My path:
C:\Users\...\Documents\Python Scripts\
import_sample.py
class class_sample(object):
def __init__(self):
self.x = ["I", "am", "doing", "something", "with", "Python"]
test.py
from import_sample import class_sample
c = class_sample()
y = c.x
print " ".join(y)
Result:
I am doing something with Python
[Finished in 0.1s]
Notice how being in the same folder allows me to import without having to install, per se. Basically, just make sure that the modules you need are in the same folder as your main.py
and you're good.
EDIT:
Done from the terminal.
Notice how I cd
into the above folder and activated python
there. Since I was inside that folder, any modules inside it can be imported without any problems, alongside other system-wide modules installed as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With