How to run project files with Anaconda from any directory on Windows

Python newbie here. I am using Anaconda (on Windows 7) as recommended by a friend.

What I want to do is make changes to my class in Notepad ++ and then immediately test it in a Python command prompt window.

This is a simple question that I cannot find an answer to: in which directory does the default Anaconda installation expect me to store my .py files (so that I can easily download them with import <MODULE NAME>

)?

My PATH variable is: C:\USERS\<USERNAME>\Anaconda3;C:\USERS\<USERNAME>\Anaconda3\Scripts

(this is the default)

I have to work from a directory Scripts

...? There are already many files there.

What are most people doing? Perhaps add another folder to your PATH variable and work from there? Are you adding a new folder to PATH for each project or is there a way that makes more sense? I already have a project directory that I use for everything else. I would just like to get a job from there.

I am coding in Notepad ++. I really don't want to worry about setting up / learning the IDE (I'm just doing the relatively simple file I / O manipulations I previously did in Excel ... horror).

Sorry for the extremely new question. I searched and didn't find anything suitable.

EDIT AFTER ANSWER ACCEPTED:

The problem was that I was running python.exe from the start menu. I didn't understand that you have to open a CMD window in the (SHIFT + RIGHT CLICK) folder you are working in (for example C:\USERS\<USERNAME>\MY PYTHON STUFF

) and run python from there.

+3


source to share


1 answer


This may be what you are trying to do. Please note that I am using Anaconda as well.

My way:

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]

      

Please note that using the same folder allows me to import without having to install. Basically, make sure the modules you want are in the same folder as yours main.py

and you're good to go.

EDIT:

Executed from the terminal.

enter image description here

Notice how I am cd

in the above folder and activated python

there. Since I was inside this folder, any modules inside it can be imported without any problem, along with other installed system modules.

+3


source







All Articles