翻译进度
3
分块数量
0
参与人数

安装 Python

这是一篇协同翻译的文章,你可以点击『我来翻译』按钮来参与翻译。

《Django Girls》的 中文翻译 1.8 版本 已经翻译完成,请在参考 1.8 版本的基础上进行校正和翻译。


Let’s start with Python

We're finally here!

But first, let us tell you what Python is. Python is a very popular programming language that can be used for creating websites, games, scientific software, graphics, and much, much more.

Python originated in the late 1980s and its main goal is to be readable by human beings (not only machines!). This is why it looks simpler than other programming languages, but don't worry – Python is also really powerful!

Python installation

Note If you're using a Chromebook, skip this chapter and make sure you follow the Chromebook Setup instructions.

Note If you already worked through the Installation steps, there's no need to do this again – you can skip straight ahead to the next chapter!

For readers at home: this chapter is covered in the Installing Python & Code Editor video.

This section is based on a tutorial by Geek Girls Carrots (https://github.com/ggcarrots/django-carrot...)

Django is written in Python. We need Python to do anything in Django. Let's start by installing it! We want you to install the latest version of Python 3, so if you have any earlier version, you will need to upgrade it. If you already have version 3.4 or higher you should be fine.

Please install normal Python as follows, even when you have Anaconda installed on your computer.

Install Python: Windows

First check whether your computer is running a 32-bit version or a 64-bit version of Windows, on the "System type" line of the System Info page. To reach this page, try one of these methods:

  • Press the Windows key and Pause/Break key at the same time
  • Open your Control Panel from the Windows menu, then navigate to System & Security, then System
  • Press the Windows button, then navigate to Settings > System > About

You can download Python for Windows from the website https://www.python.org/downloads/windows/. Click on the "Latest Python 3 Release - Python x.x.x" link. If your computer is running a 64-bit version of Windows, download the Windows x86-64 executable installer. Otherwise, download the Windows x86 executable installer. After downloading the installer, you should run it (double-click on it) and follow the instructions there.

One thing to watch out for: During the installation, you will notice a window marked "Setup". Make sure you tick the "Add Python 3.6 to PATH" or 'Add Python to your environment variables" checkbox and click on "Install Now", as shown here (it may look a bit different if you are installing a different version):

Don't forget to add Python to the Path

When the installation completes, you may see a dialog box with a link you can follow to learn more about Python or about the version you installed. Close or cancel that dialog -- you'll be learning more in this tutorial!

Note: if you are using an older version of Windows (7, Vista, or any older version) and the Python 3.6.x installer fails with an error, you can try either:

  1. install all Windows Updates and try to install Python again; or
  2. install an older version of Python, e.g., 3.4.6.

If you install an older version of Python, the installation screen may look a bit different than shown above. Make sure you scroll down to see "Add python.exe to Path", then click the button on the left and pick "Will be installed on local hard drive":

Add Python to the Path, older versions

Install Python: OS X

Note Before you install Python on OS X, you should ensure your Mac settings allow installing packages that aren't from the App Store. Go to System Preferences (it's in the Applications folder), click "Security & Privacy," and then the "General" tab. If your "Allow apps downloaded from:" is set to "Mac App Store," change it to "Mac App Store and identified developers."

You need to go to the website https://www.python.org/downloads/release/p... and download the Python installer:

  • Download the Mac OS X 64-bit/32-bit installer file,
  • Double click python-3.6.1-macosx10.6.pkg to run the installer.

Install Python: Linux

It is very likely that you already have Python installed out of the box. To check if you have it installed (and which version it is), open a console and type the following command:

command-line

$ python3 --version
Python 3.6.1

If you have a different version of Python installed, at least 3.4.0 (e.g. 3.6.0), then you don't have to upgrade. If you don't have Python installed, or if you want a different version, first check what Linux distribution you are using with the following command:

command-line

$ grep ^NAME= /etc/os-release

Afterwards, depending on the result, follow one of the following installation guides below this section.

Install Python: Debian or Ubuntu

Type this command into your console:

command-line

$ sudo apt install python3

Install Python: Fedora

Use this command in your console:

command-line

$ sudo dnf install python3

If you're on older Fedora versions you might get an error that the command dnf is not found. In that case, you need to use yum instead.

Install Python: openSUSE

Use this command in your console:

command-line

$ sudo zypper install python3

Verify the installation was successful by opening a command prompt and running the python3 command:

command-line

$ python3 --version
Python 3.6.1

The version shown may be different from 3.6.1 -- it should match the version you installed.

NOTE: If you're on Windows and you get an error message that python3 wasn't found, try using python (without the 3) and check if it still might be a version of Python that is 3.4.0 or higher. If that doesn't work either, you may open a new command prompt and try again; this happens if you use a command prompt left open from before the Python installation.


If you have any doubts, or if something went wrong and you have no idea what to do next, please ask your coach! Sometimes things don't go smoothly and it's better to ask for help from someone with more experience.

本文章首发在 LearnKu.com 网站上。

本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

Summer
讨论数量: 0
发起讨论 只看当前版本


暂无话题~