Skip to content

Commit 677edb2

Browse files
committed
10.13小节完成
1 parent f225bbc commit 677edb2

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

source/c10/p13_installing_packages_just_for_yourself.rst

+14-23
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,37 @@
55
----------
66
问题
77
----------
8-
You want to install a third-party package, but you don’t have permission to install packages
9-
into the system Python. Alternatively, perhaps you just want to install a package
10-
for your own use, not all users on the system.
8+
你想要安装一个第三方包,但是没有权限将它安装到系统Python库中去。
9+
或者,你可能想要安装一个供自己使用的包,而不是系统上面所有用户。
1110

1211
----------
1312
解决方案
1413
----------
15-
Python has a per-user installation directory that’s typically located in a directory such
16-
as ~/.local/lib/python3.3/site-packages. To force packages to install in this directory, give
17-
the --user option to the installation command. For example:
14+
Python有一个用户安装目录,通常类似"~/.local/lib/python3.3/site-packages"。
15+
要强制在这个目录中安装包,可使用安装选项“--user”。例如:
1816

1917
.. code-block:: python
2018
2119
python3 setup.py install --user
2220
23-
or
21+
或者
2422

2523
.. code-block:: python
2624
2725
pip install --user packagename
2826
29-
The user site-packages directory normally appears before the system site-packages directory
30-
on sys.path. Thus, packages you install using this technique take priority over
31-
the packages already installed on the system (although this is not always the case depending
32-
on the behavior of third-party package managers, such as distribute or pip).
27+
在sys.path中用户的“site-packages”目录位于系统的“site-packages”目录之前。
28+
因此,你安装在里面的包就比系统已安装的包优先级高
29+
(尽管并不总是这样,要取决于第三方包管理器,比如distribute或pip)。
30+
3331

3432
----------
3533
讨论
3634
----------
37-
Normally, packages get installed into the system-wide site-packages directory, which is
38-
found in a location such as /usr/local/lib/python3.3/site-packages. However, doing so
39-
typically requires administrator permissions and use of the sudo command. Even if you
40-
have permission to execute such a command, using sudo to install a new, possibly unproven,
41-
package might give you some pause.
42-
43-
44-
Installing packages into the per-user directory is often an effective workaround that
45-
allows you to create a custom installation.
46-
35+
通常包会被安装到系统的site-packages目录中去,路径类似“/usr/local/lib/python3.3/site-packages”。
36+
不过,这样做需要有管理员权限并且使用sudo命令。
37+
就算你有这样的权限去执行命令,使用sudo去安装一个新的,可能没有被验证过的包有时候也不安全。
4738

48-
As an alternative, you can also create a virtual environment, which is discussed in the
49-
next recipe.
39+
安装包到用户目录中通常是一个有效的方案,它允许你创建一个自定义安装。
5040

41+
另外,你还可以创建一个虚拟环境,这个我们在下一节会讲到。

0 commit comments

Comments
 (0)