python在anaconda哪个文件夹_如何使用Anaconda从Windows中的任何目录运行项目文件

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 )?

My PATH variable is set to:

C:\USERS\\Anaconda3;C:\USERS\\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\\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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值