Mac Swampy(Python学习模块)安装

发布于 2024-10-29 01:52:58 字数 1024 浏览 0 评论 0原文

我想教我的孩子们编程,并且正在使用 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

可能是非常明显的,为介绍文本买硬的东西!

更新

为以后遇到此问题的任何人记录一些详细信息:

  1. 我的安装没有文件或文件夹“python2”,因此路径名“/home/downey/swampy-2.0/” python2”可能不起作用。我刚刚删除了“python2”,一切都很好。

  2. 查找 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:

  1. 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.

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晒暮凉 2024-11-05 01:52:58

打开终端并导航到解压 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 command export PYHTONPATH="/home/downey/swampy-2.0/python2". This will set the PYTHONPATH 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". Type Ctrl+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 –

  • Go to Terminal –> Preferences –> Settings –> Shell.
  • Check ‘Run Command’ and enter source ~/.bashrc.
  • NOTE: These settings are only need to be applied to each profile separately. For example if you applied these settings to the Basic profile, they won’t be applicable to Grass profile.

Hope this helps!

许仙没带伞 2024-11-05 01:52:58

将变量添加到路径的一个简单方法是将它们添加到位于您的 home 目录中的 .bash_profile 中。每次打开终端时都会加载此文件。它是一个隐藏文件,因此您将无法在 Finder 中查看它(默认情况下) 。打开新的终端窗口后运行此命令:

open -a TextEdit .bash_profile

这将在新的文本编辑窗口中打开配置文件。添加这个 &保存:

PYTHONPATH=${PYTHONPATH}:/home/downey/swampy-2.0/python2
export PYTHONPATH

假设您的 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:

open -a TextEdit .bash_profile

This will open the profile up in a new TextEdit window. Add this & save:

PYTHONPATH=${PYTHONPATH}:/home/downey/swampy-2.0/python2
export PYTHONPATH

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文