Mac Swampy(Python学习模块)安装
我想教我的孩子们编程,并且正在使用 Downey 的“Think Python”。这本书很棒,除了他安装“Swampy”一个类似海龟的学习模块时。我花了几个小时试图弄清楚——现在我需要帮助。
任何人都可以提供有关如何安装 Swampy 的清晰、分步说明吗?请假设对 Unix 等的先验知识为零。
我使用的是 OS X (10.6.6)。 Python 运行良好。 Tkinter 很好。
以下是作者网站上提供的总体安装说明:
http://www.greenteapress。 com/thinkpython/swampy/install.html
我被困在“将 Swampy 添加到您的搜索路径”部分。
以下是作者指出的有关搜索路径的附加说明:
http: //docs.python.org/install/index.html#inst-search-path
可能是非常明显的,为介绍文本买硬的东西!
更新
为以后遇到此问题的任何人记录一些详细信息:
我的安装没有文件或文件夹“python2”,因此路径名“/home/downey/swampy-2.0/” python2”可能不起作用。我刚刚删除了“python2”,一切都很好。
查找 bashpc 或 bash_profile 文件时遇到一些问题。即使在寻找隐藏文件时也似乎不存在。所以我刚刚创建了一个新的。一切似乎都很好。
再次感谢您的帮助 - 我永远不会弄清楚:)
我很惊讶没有某种安装程序或脚本来处理这本书的读者(像我这样的新手)。 :)
I thought I would teach my kids programming and am using "Think Python" by Downey. The book is great except when he gets to installing "Swampy" a Turtle-like learning module. I've spent a few hours trying to figure it out--now I need help.
Can anyone offer a clear, step-by-step set of instructions on how to install Swampy? Please assume zero prior knowledge of Unix, etc.
I'm on OS X (10.6.6). Python is running fine. Tkinter is fine.
Here are the overall installation instructions offered at the author's site:
http://www.greenteapress.com/thinkpython/swampy/install.html
I am stuck at the "Add Swampy to your search path" section.
Here are the additional instructions the author points to regarding the search path:
http://docs.python.org/install/index.html#inst-search-path
Probably terribly obvious buy tough stuff for an intro text!
Update
A few details for the record for anyone who comes across this later:
My installation does not have a file or folder "python2" so the pathname "/home/downey/swampy-2.0/python2" might not work. I just dropped the "python2" and all was well.
Had a bit of a problem finding the bashpc or bash_profile file. Didn't seem to exist even when looking for hidden files. So I just created a new one. All seems well.
Thanks again for your help--I would never have figured it out :)
I'm surprised there isn't some sort of installer or script to handle this given the audience for the book (newbies like me). :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打开终端并导航到解压 Swampy 的文件夹。通过输入
pwd
查找该位置的完整目录路径。假设位置是/home/downey/sampy-2.0/python2
。现在在终端中发出此命令export PYHTONPATH="/home/downey/sampy-2.0/python2"
。这将设置PYTHONPATH环境变量
。如果工作正常,您需要确保在打开终端时始终运行。为此,您需要在计算机上编辑一个名为
.bashrc
的文件。在终端中,尝试
nano ~/.bashrc
。这将打开一个简单的文本编辑器。在该文件中添加相同的行
export PYHTONPATH="/home/downey/swampy-2.0/python2"
。输入Ctrl+X
关闭并确保保存。现在,您不必总是手动设置环境变量,只需执行
source ~/.bashrc
即可,这将为您执行命令。请注意,每次退出并重新打开终端时,都需要运行
source ~/.bashrc
来设置 PYTHONPATH。如果您不想每次都运行 source ~/.bashrc打开终端,您可以将终端配置为在启动时(即打开终端窗口时)自动运行此命令。为此 –source ~/.bashrc
。希望这有帮助!
Open the terminal and navigate to the folder where you unzipped Swampy. Find the full directory path of that location by typing
pwd
. Let's say that location is/home/downey/swampy-2.0/python2
. Now in the terminal issue this commandexport PYHTONPATH="/home/downey/swampy-2.0/python2"
. This will set thePYTHONPATH environment variable
.If that works fine, you need to make sure that this always runs when you open the terminal. For that you need to edit a file called
.bashrc
on your computer.In the terminal, try
nano ~/.bashrc
.That will open a simple text editor. In that file add the same line
export PYHTONPATH="/home/downey/swampy-2.0/python2"
. TypeCtrl+X
to close and make sure you save.Now instead of always setting the environment variable manually, you can just do
source ~/.bashrc
and that will execute the command for you.Note that every time you exit and reopen the terminal, you need to run
source ~/.bashrc
for the PYTHONPATH to be set.If you don’t want to run source ~/.bashrc every time you open the terminal, you can configure the Terminal to automatically run this command at startup (i.e. when the terminal window is opened). To do that –source ~/.bashrc
.Hope this helps!
将变量添加到路径的一个简单方法是将它们添加到位于您的 home 目录中的 .bash_profile 中。每次打开终端时都会加载此文件。它是一个隐藏文件,因此您将无法在 Finder 中查看它(默认情况下) 。打开新的终端窗口后运行此命令:
这将在新的文本编辑窗口中打开配置文件。添加这个 &保存:
假设您的 Swampy 下载路径与网站 (/home/downey/swampy-2.0/python2) 相同,那么下次运行终端时,现在应该包含该路径。
An easy way to add variables to your path is to add them to your .bash_profile, which is located in your home directory. This file loads every time you open up terminal. It is a hidden file, so you will not be able to view it (by default) in Finder. Run this command after opening a new terminal window:
This will open the profile up in a new TextEdit window. Add this & save:
Assuming your Swampy download path is the same from the Web Site (/home/downey/swampy-2.0/python2), the next time you run terminal, the path should now be included.