mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
91aac22be5
184
published/20140119 10 Killer Tips To Speed Up Ubuntu Linux.md
Normal file
184
published/20140119 10 Killer Tips To Speed Up Ubuntu Linux.md
Normal file
@ -0,0 +1,184 @@
|
||||
10 条加速 Ubuntu Linux 的杀手级技巧
|
||||
======
|
||||
|
||||
> 一些实用的**加速 Ubuntu Linux 的技巧**。 这里的技巧对于大多数版本的 Ubuntu 是有效的,也可以应用于 Linux Mint 以及其他的基于 Ubuntu 的发行版。
|
||||
|
||||
也许你经历过使用 Ubuntu 一段时间后系统开始运行缓慢的情况。 在这篇文章里,我们将看到几项调整以及使 Ubuntu 运行更快的窍门。
|
||||
|
||||
在我们了解如何提升 Ubuntu 的总体系统表现之前,首先让我们思考为什么系统逐渐变慢。这个问题可能有很多原因。也许你有一台只有基础配置的简陋的电脑;也许你安装了一些在启动时即耗尽资源的应用。事实上原因无穷无尽。
|
||||
|
||||
这里我列出一些能够帮助你稍微加速 Ubuntu 的小调整。也有一些你能够采用以获取一个更流畅、有所提升的系统表现的经验。你可以选择遵循全部或部分的建议。将各项调整一点一点的结合就能给你一个更流畅、更迅捷快速的 Ubuntu。
|
||||
|
||||
### 使 Ubuntu 更快的技巧
|
||||
|
||||
![Tips to speed up Ubuntu][1]
|
||||
|
||||
我在一个较老版本的 Ubuntu 上使用了这些调整,但是我相信其他的 Ubuntu 版本以及其他的例如 Linux Mint、 Elementary OS Luna 等基 Ubuntu 的 Linux 版本也是同样适用的。
|
||||
|
||||
#### 1、 减少默认的 grub 载入时间
|
||||
|
||||
Grub 给你 10 秒的时间以让你在多系统启动项或恢复模式之间改变。对我而言,它是多余的。它也意味着你将不得不坐在电脑旁,敲下回车键以尽可能快的启动进入 Ubuntu。这花了一点时间,不是吗? 第一个技巧便是改变这个启动时间。如果你使用图形工具更舒适,阅读这篇文章来[使用 Grub 定制器改变 grub 时间以及启动顺序][2]。
|
||||
|
||||
如果更倾向于命令行,你可以简单地使用以下的命令来打开 grub 配置:
|
||||
|
||||
```
|
||||
sudo gedit /etc/default/grub &
|
||||
```
|
||||
|
||||
并且将 `GRUB_TIMEOUT=10` 改为 `GRUB_TIMEOUT=2`。这将改变启动时间为 2 秒。最好不要将这里改为 0,因为这样你将会失去在操作系统及恢复选项之间切换的机会。一旦你更改了 grub 配置,使用以下命令来使更改生效:
|
||||
|
||||
```
|
||||
sudo update-grub
|
||||
```
|
||||
|
||||
#### 2、 管理开机启动的应用
|
||||
|
||||
渐渐地你开始安装各种应用。 如果你是我们的老读者, 你也许从 [App of the week][3] 系列安装了许多应用。
|
||||
|
||||
这些应用中的一些在每次开机时都会启动,当然资源运行这些应用也会陷入繁忙。结果:一台电脑因为每次启动时的持续时间而变得缓慢。进入 Unity Dash 寻找 “Startup Applications”:
|
||||
|
||||

|
||||
|
||||
在这里,看看哪些应用在开机时被载入。现在考虑在你每次启动 Ubuntu 时是否有不需要启动的应用。尽管移除它们:
|
||||
|
||||

|
||||
|
||||
但是要是你不想从启动里移除它们怎么办?举个例子,如果你安装了 [Ubuntu 最好的指示器程序][4]之一, 你将想要它们在每次开机时自动地启动。
|
||||
|
||||
这里你所能做的就是延迟一些程序的启动时间。这样你将能够释放开机启动时的资源,并且一段时间后你的应用将被自动启动。在上一张图片里点击 Edit 并使用 sleep 选项来更改运行命令。
|
||||
|
||||
例如,如果你想要延迟 Dropbox 指示器的运行,我们指定时间 20 秒,你只需要在已有的命令里像这样**加入一个命令**:
|
||||
|
||||
```
|
||||
sleep 20;
|
||||
```
|
||||
|
||||
所以,命令 `dropbox start -i` 变为 `sleep 20; drobox start -i` 。这意味着现在 Dropbox 将延迟 20 秒启动。你可以通过相似的方法来改变另一个开机启动应用的启动时间。
|
||||
|
||||

|
||||
|
||||
#### 3、 安装 preload 来加速应用载入时间:
|
||||
|
||||
Preload 是一个后台运行的守护进程,它分析用户行为和频繁运行的应用。打开终端,使用如下的命令来安装 preload:
|
||||
|
||||
```
|
||||
sudo apt-get install preload
|
||||
```
|
||||
|
||||
安装后,重启你的电脑就不用管它了。它将在后台工作。[阅读更多关于preload][5]
|
||||
|
||||
#### 4、 选择最好的软件更新镜像
|
||||
|
||||
验证你更新软件是否正在使用最好的镜像是很好的做法。Ubuntu 的软件仓库镜像跨过全球,使用离你最近的一个是相当明智的。随着从服务器获取包的时间减少,这将形成更快的系统更新。
|
||||
|
||||
在 “Software & Updates->Ubuntu Software tab->Download From” 里选择 “Other” 紧接着点击 “Select Best Server”:
|
||||
|
||||

|
||||
|
||||
它将运行测试来告知你那个是最好的镜像。正常地,最好的镜像已经被设置,但是我说过,验证它没什么坏处。并且,如果仓库缓存的最近的镜像没有频繁更新的话,这将引起获取更新时的一些延迟。这对于网速相对慢的人们是有用的。你可以使用这些技巧来[加速 Ubuntu 的 wifi][6]。
|
||||
|
||||
#### 5、 为了更快的更新,使用 apt-fast 而不是 apt-get
|
||||
|
||||
`apt-fast` 是 `apt-get` 的一个 shell 脚本包装器,通过从多连接同时下载包来提升更新及包下载速度。 如果你经常使用终端以及 `apt-get` 来安装和更新包,你也许会想要试一试 `apt-fast`。使用下面的命令来通过官方 PPA 安装 `apt-fast`:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:apt-fast/stable
|
||||
sudo apt-get update
|
||||
sudo apt-get install apt-fast
|
||||
```
|
||||
|
||||
#### 6、 从 apt-get 更新移除语言相关的 ign
|
||||
|
||||
你曾经注意过 `sudo apt-get` 更新的输出吗?其中有三种行,`hit`、`ign` 和 `get`。 你可以在[这里][7]阅读它们的意义。如果你看到 IGN 行,你会发现它们中的大多数都与语言翻译有关。如果你使用所有的英文应用及包,你将完全不需要英文向英文的包数据库的翻译。
|
||||
|
||||
如果你从 `apt-get` 制止语言相关的更新,它将略微地增加 `apt-get` 的更新速度。为了那样,打开如下的文件:
|
||||
|
||||
```
|
||||
sudo gedit /etc/apt/apt.conf.d/00aptitude
|
||||
```
|
||||
|
||||
然后在文件末尾添加如下行:
|
||||
|
||||
```
|
||||
Acquire::Languages "none";
|
||||
```
|
||||
|
||||
[![speed up apt get update in Ubuntu][8]][9]
|
||||
|
||||
#### 7、 减少过热
|
||||
|
||||
现在过热是电脑普遍的问题。一台过热的电脑运行相当缓慢。当你的 CPU 风扇转得像 [尤塞恩·博尔特][10] 一样快,打开一个程序将花费很长的时间。有两个工具你可以用来减少过热,使 Ubuntu 获得更好的系统表现,即 TLP 和 CPUFREQ。
|
||||
|
||||
在终端里使用以下命令来安装 TLP:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:linrunner/tlp
|
||||
sudo apt-get update
|
||||
sudo apt-get install tlp tlp-rdw
|
||||
sudo tlp start
|
||||
```
|
||||
|
||||
安装完 TLP 后你不需要做任何事。它在后台工作。
|
||||
|
||||
使用如下命令来安装 CPUFREQ 指示器:
|
||||
|
||||
```
|
||||
sudo apt-get install indicator-cpufreq
|
||||
```
|
||||
|
||||
重启你的电脑并使用 Powersave 模式:
|
||||
|
||||

|
||||
|
||||
#### 8、 调整 LibreOffice 来使它更快
|
||||
|
||||
如果你是频繁使用 office 产品的用户,那么你会想要稍微调整默认的 LibreOffice 使它更快。这里你将调整内存选项。打开 Open LibreOffice,进入 “Tools->Options”。在那里,从左边的侧栏选择“Memory”并启用 “Systray Quickstarter” 以及增加内存分配。
|
||||
|
||||

|
||||
|
||||
你可以阅读更多关于[如何提速 LibreOffice][11] 的细节。
|
||||
|
||||
#### 9、 使用轻量级的桌面环境 (如果你可以)
|
||||
|
||||
如果你选择安装默认的 Unity of GNOME 桌面环境, 你也许会选择一个轻量级的桌面环境像 [Xfce][12] 或 [LXDE][13]。
|
||||
|
||||
这些桌面环境使用更少的内存,消耗更少的 CPU。它们也自带轻量应用集来更深入地帮助更快地使用 Ubuntu。你可以参考这篇详细指南来学习[如何在 Ubuntu 上安装 Xfce][14]。
|
||||
|
||||
当然,桌面也许没有 Unity 或 GNOME 看起来现代化。那是你必须做出的妥协。
|
||||
|
||||
#### 10、 使用不同应用的更轻量可选
|
||||
|
||||
这不仅仅是建议和喜好。一些默认的或者流行的应用是耗资源的且可能不适合低端的电脑。你能做的就是使用这些应用的一些替代品。例如,使用 [AppGrid][15] 而不是 Ubuntu 软件中心。使用 [Gdebi][16] 来安装包。使用 AbiWord 而不是 LibreOffice Writer 等。
|
||||
|
||||
可以断定这些技巧的汇总使 Ubuntu 14.04,16.04 以及其他版本更快。我确定这些技巧会提供一个总体上更好的系统表现。
|
||||
|
||||
对于加速 Ubuntu 你也有妙计吗?这些技巧也帮到你了吗?分享你的观点。 问题,建议总是受欢迎的。请在评论区里提出来。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/speed-up-ubuntu-1310/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[darsh8](https://github.com/darsh8)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[1]:https://itsfoss.com/wp-content/uploads/2017/07/speed-up-ubuntu-featured-800x450.jpeg
|
||||
[2]:https://itsfoss.com/windows-default-os-dual-boot-ubuntu-1304-easy/ (Make Windows Default OS In Dual Boot With Ubuntu 13.04: The Easy Way)
|
||||
[3]:https://itsfoss.com/tag/app-of-the-week/
|
||||
[4]:https://itsfoss.com/best-indicator-applets-ubuntu/ (7 Best Indicator Applets For Ubuntu 13.10)
|
||||
[5]:https://itsfoss.com/improve-application-startup-speed-with-preload-in-ubuntu/ (Improve Application Startup Speed With Preload in Ubuntu)
|
||||
[6]:https://itsfoss.com/speed-up-slow-wifi-connection-ubuntu/ (Speed Up Slow WiFi Connection In Ubuntu 13.04)
|
||||
[7]:http://ubuntuforums.org/showthread.php?t=231300
|
||||
[8]:https://itsfoss.com/wp-content/uploads/2014/01/ign_language-apt_get_update-e1510129903529.jpeg
|
||||
[9]:https://itsfoss.com/wp-content/uploads/2014/01/ign_language-apt_get_update.jpeg
|
||||
[10]:http://en.wikipedia.org/wiki/Usain_Bolt
|
||||
[11]:https://itsfoss.com/speed-libre-office-simple-trick/ (Speed Up LibreOffice With This Simple Trick)
|
||||
[12]:https://xfce.org/
|
||||
[13]:https://lxde.org/
|
||||
[14]:https://itsfoss.com/install-xfce-desktop-xubuntu/
|
||||
[15]:https://itsfoss.com/app-grid-lighter-alternative-ubuntu-software-center/ (App Grid: Lighter Alternative Of Ubuntu Software Center)
|
||||
[16]:https://itsfoss.com/install-deb-files-easily-and-quickly-in-ubuntu-12-10-quick-tip/ (Install .deb Files Easily And Quickly In Ubuntu 12.10 [Quick Tip])
|
@ -1,53 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
Let's migrate away from GitHub
|
||||
======
|
||||
As many of you heard today, [Microsoft is acquiring GitHub][1]. What this means for the future of GitHub is not yet clear, but [the folks at Gitlab][2] think Microsoft's end goal is to integrate GitHub in their Azure empire. To me, this makes a lot of sense.
|
||||
|
||||
Even though I still reluctantly use GitHub for some projects, I migrated all my personal repositories to Gitlab instances a while ago. Now is time for you to do the same and ditch GitHub.
|
||||
|
||||
![Microsft loven't Linux][3]
|
||||
|
||||
Some people might be fine with Microsoft's takeover, but to me it's the straw that breaks the camel's back. For a few years now, MS has been running a large marketing campaign on how they love Linux and suddenly decided to embrace Free Software in all of its forms. More like MS BS to me.
|
||||
|
||||
Let us take a moment to remind ourselves that:
|
||||
|
||||
* Windows is still a huge proprietary monster that rips billions of people from their privacy and rights every day.
|
||||
* Microsoft is known for spreading FUD about "the dangers" of Free Software in order to keep governments and schools from dropping Windows in favor of FOSS.
|
||||
* To secure their monopoly, Microsoft hooks up kids on Windows by giving out "free" licences to primary schools around the world. Drug dealers use the same tactics and give out free samples to secure new clients.
|
||||
* Microsoft's Azure platform - even though it can run Linux VMs - is still a giant proprietary hypervisor.
|
||||
|
||||
|
||||
|
||||
I know moving git repositories around can seem like a pain in the ass, but the folks at Gitlab are riding the wave of people leaving GitHub and made the the migration easy [by providing a GitHub importer][4].
|
||||
|
||||
If you don't want to use Gitlab's main instance ([gitlab.org][5]), here are two other alternative instances you can use for Free Software projects:
|
||||
|
||||
* The [Debian Gitlab instance][6] is available for every FOSS project and not only for Debian-related ones. As long as the project respects the [Debian Free Software Guidelines][7], you can use the instance and its CI runners.
|
||||
* Riseup maintains a Gitlab instance for radical projects named [0xacab][8]. If your [ethos aligns with Riseup's][9], chances are they'll be happy to host your projects there.
|
||||
|
||||
|
||||
|
||||
Friends don't let friends use GitHub anymore.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://veronneau.org/lets-migrate-away-from-github.html
|
||||
|
||||
作者:[Louis-Philippe Véronneau][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://veronneau.org/
|
||||
[1]:https://www.bloomberg.com/news/articles/2018-06-03/microsoft-is-said-to-have-agreed-to-acquire-coding-site-github
|
||||
[2]:https://about.gitlab.com/2018/06/03/microsoft-acquires-github/
|
||||
[3]:https://veronneau.org/media/blog/2018-06-03/ms-lovent-linux.png (Microsoft loven't Linux)
|
||||
[4]:https://docs.gitlab.com/ee/user/project/import/github.html
|
||||
[5]:https://gitlab.org
|
||||
[6]:https://salsa.debian.org
|
||||
[7]:https://en.wikipedia.org/wiki/Debian_Free_Software_Guidelines
|
||||
[8]:https://0xacab.org
|
||||
[9]:https://riseup.net/en/about-us/politics
|
@ -1,3 +1,5 @@
|
||||
Translating by jessie-pang
|
||||
|
||||
Container Basics: Terms You Need to Know
|
||||
======
|
||||
|
||||
|
@ -1,136 +0,0 @@
|
||||
Translating by MjSeven
|
||||
|
||||
|
||||
Why Python devs should use Pipenv
|
||||
======
|
||||
|
||||

|
||||
|
||||
This article was co-written with [Jeff Triplett][1].
|
||||
|
||||
Pipenv, the "Python Development Workflow for Humans" created by Kenneth Reitz a little more than a year ago, has become the [official Python-recommended resource][2] for managing package dependencies. But there is still confusion about what problems it solves and how it's more useful than the standard workflow using `pip` and a `requirements.txt` file. In this month's Python column, we'll fill in the gaps.
|
||||
|
||||
### A brief history of Python package installation
|
||||
|
||||
To understand the problems that Pipenv solves, it's useful to show how Python package management has evolved.
|
||||
|
||||
Take yourself back to the first Python iteration. We had Python, but there was no clean way to install packages.
|
||||
|
||||
Then came [Easy Install][3], a package that installs other Python packages with relative ease. But it came with a catch: it wasn't easy to uninstall packages that were no longer needed.
|
||||
|
||||
Enter [pip][4], which most Python users are familiar with. `pip` lets us install and uninstall packages. We could specify versions, run `pip freeze > requirements.txt` to output a list of installed packages to a text file, and use that same text file to install everything an app needed with `pip install -r requirements.txt`.
|
||||
|
||||
But `pip` didn't include a way to isolate packages from each other. We might work on apps that use different versions of the same libraries, so we needed a way to enable that. Along came [virtual environments][5], which enabled us to create small, isolated environments for each app we worked on. We've seen many tools for managing virtual environments: [virtualenv][6], [venv][7], [virtualenvwrapper][8], [pyenv][9], [pyenv-virtualenv][10], [pyenv-virtualenvwrapper][11], and even more. They all play well with `pip` and `requirements.txt` files.
|
||||
|
||||
### The new kid: Pipenv
|
||||
|
||||
Pipenv aims to solve several problems.
|
||||
|
||||
`pip` library for package installation, plus a library for creating a virtual environment, plus a library for managing virtual environments, plus all the commands associated with those libraries. That's a lot to manage. Pipenv ships with package management and virtual environment support, so you can use one tool to install, uninstall, track, and document your dependencies and to create, use, and organize your virtual environments. When you start a project with it, Pipenv will automatically create a virtual environment for that project if you aren't already using one.
|
||||
|
||||
First, the problem of needing thelibrary for package installation, plus a library for creating a virtual environment, plus a library for managing virtual environments, plus all the commands associated with those libraries. That's a lot to manage. Pipenv ships with package management and virtual environment support, so you can use one tool to install, uninstall, track, and document your dependencies and to create, use, and organize your virtual environments. When you start a project with it, Pipenv will automatically create a virtual environment for that project if you aren't already using one.
|
||||
|
||||
Pipenv accomplishes this dependency management by abandoning the `requirements.txt` norm and trading it for a new document called a [Pipfile][12]. When you install a library with Pipenv, a `Pipfile` for your project is automatically updated with the details of that installation, including version information and possibly the Git repository location, file path, and other information.
|
||||
|
||||
Second, Pipenv wants to make it easier to manage complex interdependencies. Your app might depend on a specific version of a library, and that library might depend on a specific version of another library, and it's just dependencies and turtles all the way down. When two libraries your app uses have conflicting dependencies, your life can become hard. Pipenv wants to ease that pain by keeping track of a tree of your app's interdependencies in a file called `Pipfile.lock`. `Pipfile.lock` also verifies that the right versions of dependencies are used in production.
|
||||
|
||||
Also, Pipenv is handy when multiple developers are working on a project. With a `pip` workflow, Casey might install a library and spend two days implementing a new feature using that library. When Casey commits the changes, they might forget to run `pip freeze` to update the requirements file. The next day, Jamie pulls down Casey's changes, and suddenly tests are failing. It takes time to realize that the problem is libraries missing from the requirements file that Jamie doesn't have installed in the virtual environment.
|
||||
|
||||
Because Pipenv auto-documents dependencies as you install them, if Jamie and Casey had been using Pipenv, the `Pipfile` would have been automatically updated and included in Casey's commit. Jamie and Casey would have saved time and shipped their product faster.
|
||||
|
||||
Finally, using Pipenv signals to other people who work on your project that it ships with a standardized way to install project dependencies and development and testing requirements. Using a workflow with `pip` and requirements files means that you may have one single `requirements.txt` file, or several requirements files for different environments. It might not be clear to your colleagues whether they should run `dev.txt` or `local.txt` when they're running the project on their laptops, for example. It can also create confusion when two similar requirements files get wildly out of sync with each other: Is `local.txt` out of date, or is it really supposed to be that different from `dev.txt`? Multiple requirements files require more context and documentation to enable others to install the dependencies properly and as expected. This workflow has the potential to confuse colleagues and increase your maintenance burden.
|
||||
|
||||
Using Pipenv, which gives you `Pipfile`, lets you avoid these problems by managing dependencies for different environments for you. This command will install the main project dependencies:
|
||||
```
|
||||
pipenv install
|
||||
|
||||
```
|
||||
|
||||
Adding the `--dev` tag will install the dev/testing requirements:
|
||||
```
|
||||
pipenv install --dev
|
||||
|
||||
```
|
||||
|
||||
There are other benefits to using Pipenv: It has better security features, graphs your dependencies in an easier-to-understand format, seamlessly handles `.env` files, and can automatically handle differing dependencies for development versus production environments in one file. You can read more in the [documentation][13].
|
||||
|
||||
### Pipenv in action
|
||||
|
||||
The basics of using Pipenv are detailed in the [Managing Application Dependencies][14] section of the official Python packaging tutorial. To install Pipenv, use `pip`:
|
||||
```
|
||||
pip install pipenv
|
||||
|
||||
```
|
||||
|
||||
To install packages to use in your project, change into the directory for your project. Then to install a package (we'll use Django as an example), run:
|
||||
```
|
||||
pipenv install django
|
||||
|
||||
```
|
||||
|
||||
You will see some output that indicates that Pipenv is creating a `Pipfile` for your project.
|
||||
|
||||
If you aren't already using a virtual environment, you will also see some output from Pipenv saying it is creating a virtual environment for you.
|
||||
|
||||
Then, you will see the output you are used to seeing when you install packages.
|
||||
|
||||
To generate a `Pipfile.lock` file, run:
|
||||
```
|
||||
pipenv lock
|
||||
|
||||
```
|
||||
|
||||
You can also run Python scripts with Pipenv. To run a top-level Python script called `hello.py`, run:
|
||||
```
|
||||
pipenv run python hello.py
|
||||
|
||||
```
|
||||
|
||||
And you will see your expected result in the console.
|
||||
|
||||
To start a shell, run:
|
||||
```
|
||||
pipenv shell
|
||||
|
||||
```
|
||||
|
||||
If you would like to convert a project that currently uses a `requirements.txt` file to use Pipenv, install Pipenv and run:
|
||||
```
|
||||
pipenv install requirements.txt
|
||||
|
||||
```
|
||||
|
||||
This will create a Pipfile and install the specified requirements. Consider your project upgraded!
|
||||
|
||||
### Learn more
|
||||
|
||||
Check out the Pipenv documentation, particularly [Basic Usage of Pipenv][15], to take you further. Pipenv creator Kenneth Reitz gave a talk on Pipenv, "[The Future of Python Dependency Management][16]," at a recent PyTennessee event. The talk wasn't recorded, but his [slides][17] are helpful in understanding what Pipenv does and the problems it solves.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/why-python-devs-should-use-pipenv
|
||||
|
||||
作者:[Lacey Williams Henschel][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/laceynwilliams
|
||||
[1]:https://opensource.com/users/jefftriplett
|
||||
[2]:https://packaging.python.org/tutorials/managing-dependencies/#managing-dependencies
|
||||
[3]:http://peak.telecommunity.com/DevCenter/EasyInstall
|
||||
[4]:https://packaging.python.org/tutorials/installing-packages/#use-pip-for-installing
|
||||
[5]:https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments
|
||||
[6]:https://virtualenv.pypa.io/en/stable/
|
||||
[7]:https://docs.python.org/3/library/venv.html
|
||||
[8]:https://virtualenvwrapper.readthedocs.io/en/latest/
|
||||
[9]:https://github.com/pyenv/pyenv
|
||||
[10]:https://github.com/pyenv/pyenv-virtualenv
|
||||
[11]:https://github.com/pyenv/pyenv-virtualenvwrapper
|
||||
[12]:https://github.com/pypa/pipfile
|
||||
[13]:https://docs.pipenv.org/
|
||||
[14]:https://packaging.python.org/tutorials/managing-dependencies/
|
||||
[15]:https://docs.pipenv.org/basics/
|
||||
[16]:https://www.pytennessee.org/schedule/presentation/158/
|
||||
[17]:https://speakerdeck.com/kennethreitz/the-future-of-python-dependency-management
|
@ -1,3 +1,5 @@
|
||||
translating----geekpi
|
||||
|
||||
Automatically Change Wallpapers in Linux with Little Simple Wallpaper Changer
|
||||
======
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
【翻译中 by ZenMoore】
|
||||
Historical inventory of collaborative editors
|
||||
======
|
||||
A quick inventory of major collaborative editor efforts, in chronological order.
|
||||
|
50
translated/talk/20180603 Let-s migrate away from GitHub.md
Normal file
50
translated/talk/20180603 Let-s migrate away from GitHub.md
Normal file
@ -0,0 +1,50 @@
|
||||
让我们从 GitHub 中迁移出来
|
||||
======
|
||||
正如你们今天听到的那样,[微软正在收购 GitHub][1]。这对 GitHub 的未来意味着什么尚不清楚,但[ Gitlab 的人][2]认为微软的最终目标是将 GitHub 整合到他们的 Azure 帝国。对我来说,这很有道理。
|
||||
|
||||
尽管我仍然不情愿地将 GitHub 用于某些项目,但我前一段时间将所有个人仓库迁移到了 Gitlab 中。现在是时候让你做同样的事情,并抛弃 GitHub。
|
||||
|
||||
![Microsft loven't Linux][3]
|
||||
|
||||
有些人可能认为微软的收购没有问题,但对我来说,这是压垮骆驼的最后一根稻草。几年来,微软一直在开展一场关于他们如何热爱 Linux 的大型营销活动,并突然决定用所有它的形式拥抱自由软件。更像 MS BS 给我的。
|
||||
|
||||
让我们花点时间提醒自己:
|
||||
|
||||
* Windows 仍然是一个巨大的专有怪物,每天都会将数十亿人从隐私和权利中剥离出来。
|
||||
* 微软公司以传播自由软件的“危害”闻名,以防止政府和学校放弃 Windows,转而支持 FOSS。
|
||||
* 为了确保他们的垄断地位,微软通过向全世界的小学颁发“免费”许可证来吸引孩子使用 Windows。毒品经销商使用相同的策略并提供免费样品来获取新客户。
|
||||
* 微软的 Azure 平台 - 即使它可以运行 Linux 虚拟机 - 它仍然是一个巨大的专有管理程序。
|
||||
|
||||
|
||||
|
||||
我知道移动 git 仓库看起来像是一件痛苦的事情,但是 Gitlab 的员工正在乘着离开 GitHub 的人们的浪潮,并通过[提供 GitHub 导入器][4]使迁移变得容易。
|
||||
|
||||
如果你不想使用 Gitlab 的主实例([gitlab.org][5]),下面是另外两个你可以用于自由软件项目的备选实例:
|
||||
|
||||
* [Debian Gitlab 实例][6]适用于每个 FOSS 项目,它不仅适用于与 Debian 相关的项目。只要项目符合[ Debian 自由软件指南][7],你就可以使用该实例及其 CI。
|
||||
* Riseup 为名为 [0xacab][8] 的激进项目维护了一个 Gitlab 实例。如果你的[理念与 Riseup 的一致][9],他们很乐意在那里托管你的项目。
|
||||
|
||||
|
||||
朋友不要再让人使用 Github 了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://veronneau.org/lets-migrate-away-from-github.html
|
||||
|
||||
作者:[Louis-Philippe Véronneau][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://veronneau.org/
|
||||
[1]:https://www.bloomberg.com/news/articles/2018-06-03/microsoft-is-said-to-have-agreed-to-acquire-coding-site-github
|
||||
[2]:https://about.gitlab.com/2018/06/03/microsoft-acquires-github/
|
||||
[3]:https://veronneau.org/media/blog/2018-06-03/ms-lovent-linux.png (Microsoft loven't Linux)
|
||||
[4]:https://docs.gitlab.com/ee/user/project/import/github.html
|
||||
[5]:https://gitlab.org
|
||||
[6]:https://salsa.debian.org
|
||||
[7]:https://en.wikipedia.org/wiki/Debian_Free_Software_Guidelines
|
||||
[8]:https://0xacab.org
|
||||
[9]:https://riseup.net/en/about-us/politics
|
@ -1,173 +0,0 @@
|
||||
"翻译完成"
|
||||
10条加速Ubuntu Linux的杀手级贴士
|
||||
======
|
||||
**摘要** : 一些实际的**加速Ubuntu Linux的贴士**。 这里的贴士对于大多数版本的Ubuntu是有效的,也可以应用于Linux Mint以及其他的基于Ubuntu的发行版。
|
||||
|
||||
也许你经历过使用Ubuntu一段时间后系统开始运行缓慢的情况。 在这篇文章里,我们将看到几项调整以及**使Ubuntu运行更快的窍门**。
|
||||
|
||||
在我们了解如何提升Ubuntu的总体系统表现之前,首先让我们思考为什么系统逐渐变慢。这个问题可能有很多原因。也许你有一台只有基础配置的简陋的电脑;也许你安装了一些在启动时即耗尽资源的应用。事实上原因无穷无尽。
|
||||
|
||||
这里我列出一些能够帮助你稍微加速Ubuntu的小调整。也有一些你能够采用过来以获取一个更流畅、有所提升的系统表现的最好的尝试。你可以选择遵循全部或部分的建议。将各项调整一点一点的结合就能给你一个更流畅、更迅捷快速的Ubuntu。
|
||||
|
||||
### 使Ubuntu更快的贴士:
|
||||
|
||||
![Tips to speed up Ubuntu][1]
|
||||
我在一个较老版本的Ubuntu上使用了这些调整,但是我相信其他的Ubuntu版本以及其他的例如Linux Mint, Elementary OS Luna等基于Ubuntu的Linux版本也是同样适用的。
|
||||
|
||||
#### 1\. 减少默认的grub载入时间:
|
||||
|
||||
Grub给你10秒的时间以让你在多系统启动项或恢复模式之间改变。对我而言,它是多余的。它也意味着你将不得不坐在电脑旁,敲着Enter键以尽可能快的启动进入Ubuntu。这花了一点时间,不是吗? 第一个技巧便是改变这个启动时间。如果你使用图形工具更舒适,阅读这篇文章来[使用Grub定制器改变grub时间以及启动顺序][2].
|
||||
|
||||
如果更倾向于命令行,你可以简单地使用以下的命令来打开grub配置:
|
||||
```
|
||||
sudo gedit /etc/default/grub &
|
||||
|
||||
```
|
||||
|
||||
并且将**GRUB_TIMEOUT=10**改为**GRUB_TIMEOUT=2**.这将改变启动时间为2秒。最好不要将这里改为0,因为这样你将会失去在操作系统及恢复选项之间切换的机会。一旦你更改了grub配置,使用以下命令来使更改生效:
|
||||
```
|
||||
sudo update-grub
|
||||
|
||||
```
|
||||
|
||||
#### 2\. 管理开机启动的应用:
|
||||
渐渐地你倾向于开始安装应用。 如果你是日常的“It’s FOSS”读者, 你也许从[App of the week][3]系列安装了许多apps.
|
||||
|
||||
这些apps的其中一些在每次开机时都会启动,当然资源运行这些应用也会陷入繁忙。结果:一台电脑因为每次启动时的持续时间而变得缓慢。进入Unity Dash寻找**Startup Applications** :
|
||||
|
||||

|
||||
在这里,看看哪些应用在开机时被载入。现在考虑在你每次启动Ubuntu时是否有不需要启动的应用。尽管移除它们:
|
||||
|
||||

|
||||
但是要是你不想从启动里移除它们怎么办?举个例子,如果你安装了[Ubuntu最好的指示器程序][4]之一, 你将想要它们在每次开机时自动地启动。
|
||||
|
||||
这里你所能做的就是延迟一些程序的启动时间。这样你将能够释放开机启动时的资源,并且一段时间后你的应用将被自动启动。在上一张图片里点击Edit并使用sleep选项来更改运行命令。
|
||||
例如,如果你想要延迟Dropbox指示器的运行,我们指定时间20秒,你只需要在已有的命令里像这样**加入一个命令**:
|
||||
```
|
||||
sleep 20;
|
||||
|
||||
```
|
||||
|
||||
所以,命令‘ **dropbox start -i** ‘变为‘ **sleep 20; drobox start -i** ‘。这意味着现在Dropbox将延迟20秒启动。你可以通过相似的方法来改变另一个开机启动应用的启动时间。
|
||||

|
||||
|
||||
#### 3\. 安装preload来加速应用载入时间:
|
||||
|
||||
Preload是一个后台运行的守护进程,分析用户行为,频繁地运行应用。打开终端,使用如下的命令来安装preload:
|
||||
```
|
||||
sudo apt-get install preload
|
||||
|
||||
```
|
||||
|
||||
安装后,重启你的电脑就不用管它了。它将在后台工作。[阅读更多关于preload][5]
|
||||
|
||||
#### 4\. 选择最好的软件更新镜像:
|
||||
验证你正在使用最好的更新软件的镜像是很好的做法。Ubuntu的软件仓库镜像跨过全球, 使用离你最近的一个是相当明智的。随着从服务器获取包的时间减少,这将形成更快的系统更新。
|
||||
在**Software & Updates->Ubuntu Software tab->Download From**里选择**Other**紧接着点击**Select Best Server**:
|
||||
|
||||

|
||||
它将运行测试来告知你那个是最好的镜像。正常地,最好的镜像已经被设置,但是我说过,验证它没什么坏处。并且,如果仓库缓存的最近的镜像没有频繁更新的话,这将引起获取更新时的一些延迟。这对于网速相对慢的人们是有用的。你可以使用这些贴士来[加速Ubuntu的wifi][6].
|
||||
|
||||
#### 5\. 为了更快的更新,使用apt-fast而不是apt-get:
|
||||
|
||||
apt-fast是“apt-get”的一个shell脚本包装器,通过从多连接同时下载包来提升更新及包下载速度。 如果你经常使用终端以及apt-get来安装和更新包,你也许会想要试一试apt-fast。使用下面的命令来通过官方PPA安装apt-fast:
|
||||
```
|
||||
sudo add-apt-repository ppa:apt-fast/stable
|
||||
sudo apt-get update
|
||||
sudo apt-get install apt-fast
|
||||
|
||||
```
|
||||
|
||||
#### 6\. 从apt-get更新移除语言相关的ign:
|
||||
|
||||
你曾经注意过sudo apt-get更新的输出吗?其中有三种行,**hit**,**ign**和**get**. 你可以在[这里][7]阅读它们的意义。如果你看到IGN行,你会发现它们中的大多数都与语言翻译有关。如果你使用所有的英文应用及包,你将完全不需要英文向英文的包数据库的翻译。
|
||||
|
||||
如果你从apt-get制止语言相关的更新,它将略微地增加apt-get的更新速度。为了那样,打开如下的文件:
|
||||
```
|
||||
sudo gedit /etc/apt/apt.conf.d/00aptitude
|
||||
|
||||
```
|
||||
|
||||
然后在文件末尾添加如下行:
|
||||
```
|
||||
Acquire::Languages "none";
|
||||
|
||||
```
|
||||
[![speed up apt get update in Ubuntu][8]][9]
|
||||
|
||||
#### 7\. 减少过热:
|
||||
|
||||
现在过热是电脑普遍的问题。一台过热的电脑运行相当缓慢。当你的CPU风扇转得像[Usain Bolt][10],打开一个程序将花费很长的时间。有两个工具你可以用来极少过热,使Ubuntu获得更好的系统表现,即TLP和CPUFREQ。
|
||||
|
||||
在终端里使用以下命令来安装TLP:
|
||||
```
|
||||
sudo add-apt-repository ppa:linrunner/tlp
|
||||
sudo apt-get update
|
||||
sudo apt-get install tlp tlp-rdw
|
||||
sudo tlp start
|
||||
|
||||
```
|
||||
|
||||
安装完TLP后你不需要做任何事。它在后台工作。
|
||||
|
||||
使用如下命令来安装CPUFREQ indicator:
|
||||
```
|
||||
sudo apt-get install indicator-cpufreq
|
||||
|
||||
```
|
||||
|
||||
重启你的电脑并使用**Powersave**模式:
|
||||
|
||||

|
||||
|
||||
#### 8\. 调整LibreOffice来使它更快:
|
||||
|
||||
如果你是office产品频繁使用的用户, 那么你会想要稍微调整默认的LibreOffice使它更快。这里你将调整内存选项。打开Open LibreOffice,进入**Tools- >Options**。在那里,从左边的侧栏选择**Memory**并启用 **Systray Quickstarter** 以及增加内存分配。
|
||||
|
||||

|
||||
你可以阅读更多关于[如何提速LibreOffice][11]的细节。
|
||||
|
||||
#### 9\. 使用轻量级的桌面环境 (如果你可以):
|
||||
|
||||
如果你选择安装默认的Unity of GNOME桌面环境, 你也许会选择一个轻量级的桌面环境像[Xfce][12]或[LXDE][13]。
|
||||
|
||||
这些桌面环境使用更少的内存,消耗更少的CPU。它们也自带轻量应用集来更深入地帮助更快地使用Ubuntu。你可以参考这篇详细指南来学习[如何在Ubuntu上安装Ubuntu][14]。
|
||||
|
||||
当然,桌面也许没有Unity或GNOME看起来现代化。那是你必须做出的妥协。
|
||||
|
||||
#### 10\. 使用不同应用的更轻量可选:
|
||||
|
||||
这不仅仅是建议和喜好。一些默认的或者流行的应用是耗资源的且可能不适合低端的电脑。你能做的就是使用这些应用的一些替代品。例如,使用[AppGrid][15]而不是Ubuntu软件中心。使用[Gdebi][16]来安装包。使用 AbiWord而不是LibreOffice Writer等。
|
||||
|
||||
可以断定这些贴士的汇总使Ubuntu 14.04,16.04以及其他版本更快。我确定这些贴士会提供一个总体上更好的系统表现。
|
||||
|
||||
对于**加速Ubuntu**你也有妙计吗?这些贴士也帮到你了吗?分享你的观点。 问题,建议总是受欢迎的。请在评论区里提出来。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/speed-up-ubuntu-1310/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
译者:[译者ID](https://github.com/darsh8)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[1]:https://itsfoss.com/wp-content/uploads/2017/07/speed-up-ubuntu-featured-800x450.jpeg
|
||||
[2]:https://itsfoss.com/windows-default-os-dual-boot-ubuntu-1304-easy/ (Make Windows Default OS In Dual Boot With Ubuntu 13.04: The Easy Way)
|
||||
[3]:https://itsfoss.com/tag/app-of-the-week/
|
||||
[4]:https://itsfoss.com/best-indicator-applets-ubuntu/ (7 Best Indicator Applets For Ubuntu 13.10)
|
||||
[5]:https://itsfoss.com/improve-application-startup-speed-with-preload-in-ubuntu/ (Improve Application Startup Speed With Preload in Ubuntu)
|
||||
[6]:https://itsfoss.com/speed-up-slow-wifi-connection-ubuntu/ (Speed Up Slow WiFi Connection In Ubuntu 13.04)
|
||||
[7]:http://ubuntuforums.org/showthread.php?t=231300
|
||||
[8]:https://itsfoss.com/wp-content/uploads/2014/01/ign_language-apt_get_update-e1510129903529.jpeg
|
||||
[9]:https://itsfoss.com/wp-content/uploads/2014/01/ign_language-apt_get_update.jpeg
|
||||
[10]:http://en.wikipedia.org/wiki/Usain_Bolt
|
||||
[11]:https://itsfoss.com/speed-libre-office-simple-trick/ (Speed Up LibreOffice With This Simple Trick)
|
||||
[12]:https://xfce.org/
|
||||
[13]:https://lxde.org/
|
||||
[14]:https://itsfoss.com/install-xfce-desktop-xubuntu/
|
||||
[15]:https://itsfoss.com/app-grid-lighter-alternative-ubuntu-software-center/ (App Grid: Lighter Alternative Of Ubuntu Software Center)
|
||||
[16]:https://itsfoss.com/install-deb-files-easily-and-quickly-in-ubuntu-12-10-quick-tip/ (Install .deb Files Easily And Quickly In Ubuntu 12.10 [Quick Tip])
|
132
translated/tech/20180228 Why Python devs should use Pipenv.md
Normal file
132
translated/tech/20180228 Why Python devs should use Pipenv.md
Normal file
@ -0,0 +1,132 @@
|
||||
为什么 Python 开发人员应该使用 Pipenv
|
||||
=====
|
||||
|
||||

|
||||
|
||||
这篇文章是与 [Jeff Triplett][1] 共同撰写的。
|
||||
|
||||
Pipenv 是由 Kenneth Reitz 在一年多前创建的“面向人类(to校正者:这里为人类感觉翻译为为开发者更好一点)而生的 Python 开发工作流”,它已经成为管理软件包依赖关系的[ Python 官方推荐资源][2]。但是对于它解决了什么问题,以及它如何比使用 `pip` 和 `requirements.txt` 文件的标准工作流更有用处,这两点仍然存在困惑。在本月的 Python 专栏中,我们将填补这些空白。
|
||||
|
||||
### Python 包安装简史
|
||||
|
||||
为了理解 Pipenv 所解决的问题,看一看 Python 包管理如何发展十分有用的。
|
||||
|
||||
让我们回到第一个 Python 版本,我们有 Python,但是没有干净的方法来安装软件包。
|
||||
|
||||
然后有了 [Easy Install][3],这是一个可以相对容易地安装其他 Python 包的软件包,但它也带来了一个问题:卸载不需要的包并不容易。
|
||||
|
||||
[pip][4] 登场,绝大多数 Python 用户都熟悉它。`pip` 可以让我们安装和卸载包。我们可以指定版本,运行 `pip freeze > requirements.txt` 来输出一个已安装包列表到一个文本文件,还可以用相同的文本文件配合 `pip install -r requirements.txt` 来安装一个应用程序需要的所有包。
|
||||
|
||||
但是 `pip` 并没有包含将包彼此隔离的方法。我们可能会开发使用相同库的不同版本的应用程序,因此我们需要一种方法来实现这一点。随之而来的是[虚拟环境][5],它使我们能够为我们开发的每个应用程序创建一个小型的,隔离的环境。我们已经看到了许多管理虚拟环境的工具:[virtualenv][6], [venv][7], [virtualenvwrapper][8], [pyenv][9], [pyenv-virtualenv][10], [pyenv-virtualenvwrapper][11] 等等。它们都可以很好地使用 `pip` 和 `requirements.txt` 文件。
|
||||
|
||||
### 新方法:Pipenv
|
||||
|
||||
Pipenv 旨在解决几个问题:
|
||||
|
||||
首先,问题是需要 `pip` 库来安装包,外加一个用于创建虚拟环境的库,以及用于管理虚拟环境的库,以及与这些库相关的所有命令。这些都需要管理。Pipenv 附带包管理和虚拟环境支持,因此你可以使用一个工具来安装、卸载、跟踪和记录依赖性,并创建、使用和组织你的虚拟环境。当你使用它启动一个项目时,如果你还没有使用它的话,Pipenv 将自动为该项目创建一个虚拟环境。
|
||||
|
||||
Pipenv 通过放弃 `requirements.txt` 规范转而将其移动到一个名为 [Pipfile][12] 的新文档中来完成这种依赖管理。当你使用 Pipenv 安装一个库时,项目的 `Pipfile` 会自动更新安装细节,包括版本信息,还有可能的 Git 仓库位置,文件路径和其他信息。
|
||||
|
||||
其次,Pipenv 希望能更容易地管理复杂的相互依赖关系。你的应用程序可能依赖于某个特定版本的库,而那个库可能依赖于另一个特定版本的库,而它只是依赖关系(to 校正者:这句话不太理解)。当你的应用程序使用的两个库有冲突的依赖关系时,你的情况会变得很艰难。Pipenv 希望通过在一个名为 `Pipfile.lock` 的文件中跟踪应用程序相互依赖关系树来减轻这种痛苦。`Pipfile.lock` 还会验证生产中是否使用了正确版本的依赖关系。
|
||||
|
||||
另外,当多个开发人员在开发一个项目时,Pipenv 很方便。通过 `pip` 工作流,Casey 可能会安装一个库,并花两天时间使用该库实现一个新功能。当 Casey 提交更改时,他可能会忘记运行 `pip freeze` 来更新 requirements 文件。第二天,Jamie 拉取 Casey 的变化,突然测试失败。这样会花费好一会儿才能意识到问题是在 requirements 文件中缺少相关库,而 Jamie 尚未在虚拟环境中安装这些文件。
|
||||
|
||||
因为 Pipenv 会在安装时自动记录依赖性,如果 Jamie 和 Casey 使用了 Pipenv,`Pipfile` 会自动更新并包含在 Casey 的提交中。这样 Jamie 和 Casey 就可以节省时间并更快地运送他们的产品。
|
||||
|
||||
最后,将 Pipenv 推荐给在你项目上工作的其他人,因为它使用标准化的方式来安装项目依赖项,开发和测试需求。使用 `pip` 工作流和 requirements 文件意味着你可能只有一个 `requirements.txt` 文件,或针对不同环境的多个 requirements 文件。例如,你的同事可能不清楚他们是否应该在他们的笔记本电脑上运行项目时运行 `dev.txt` 还是 `local.txt`。当两个相似的 requirements 文件彼此不同步时它也会造成混淆:`local.txt` 是否过时了,还是真的应该与 `dev.txt` 不同?多个 requirements 文件需要更多的上下文和文档,以使其他人能够按照预期正确安装依赖关系。这个工作流程有可能会混淆同时并增加你的维护负担。
|
||||
|
||||
使用 Pipenv,它会生成 `Pipfile`,通过为你管理对不同环境的依赖关系,可以避免这些问题。该命令将安装主项目依赖项:
|
||||
```
|
||||
pipenv install
|
||||
|
||||
```
|
||||
|
||||
添加 `--dev` 标志将安装 dev/testing requirements:
|
||||
```
|
||||
pipenv install --dev
|
||||
|
||||
```
|
||||
|
||||
使用 Pipenv 还有其他好处:它具有更好的安全特性,以易于理解的格式绘制你的依赖关系,无缝处理 `.env` 文件,并且可以在一个文件中自动处理开发与生产环境的不同依赖关系。你可以在[文档][13]中阅读更多内容。
|
||||
|
||||
### Pipenv 行动
|
||||
|
||||
使用 Pipenv 的基础知识在官方 Python 包管理教程[管理应用程序依赖关系][14]部分中详细介绍。要安装 Pipenv,使用 `pip`:
|
||||
```
|
||||
pip install pipenv
|
||||
|
||||
```
|
||||
|
||||
要安装在项目中使用的包,请更改为项目的目录。然后安装一个包(我们将使用 Django 作为例子),运行:
|
||||
```
|
||||
pipenv install django
|
||||
|
||||
```
|
||||
|
||||
你会看到一些输出,表明 Pipenv 正在为你的项目创建一个 `Pipfile`。
|
||||
|
||||
如果你还没有使用虚拟环境,你还会看到 Pipenv 的一些输出,说明它正在为你创建一个虚拟环境。
|
||||
|
||||
然后,你将看到你在安装包时习惯看到的输出。
|
||||
|
||||
为了生成 `Pipfile.lock` 文件,运行:
|
||||
```
|
||||
pipenv lock
|
||||
|
||||
```
|
||||
|
||||
你也可以使用 Pipenv 运行 Python 脚本。运行名为 `hello.py` 的(to 校正者:这里 top-level该怎么翻译)Python 脚本:
|
||||
```
|
||||
pipenv run python hello.py
|
||||
|
||||
```
|
||||
|
||||
你将在控制台中看到预期结果。
|
||||
|
||||
启动一个 shell,运行:
|
||||
```
|
||||
pipenv shell
|
||||
|
||||
```
|
||||
|
||||
如果你想将当前使用 `requirements.txt` 文件的项目转换为使用 Pipenv,请安装 Pipenv 并运行:
|
||||
```
|
||||
pipenv install requirements.txt
|
||||
|
||||
```
|
||||
|
||||
这将创建一个 Pipfile 并安装指定的 requirements。考虑一下升级你的项目!
|
||||
|
||||
### 了解更多
|
||||
|
||||
查看 Pipenv 文档,特别是 [Pipenv 的基本用法][15],以帮助你进一步学习。Pipenv 的创建者 Kenneth Reitz 为 Pipenv 在最近的 PyTennessee 发表了一篇演讲:“[Python 依赖管理的未来][16]”。这次演讲没有被记录下来,但他的[幻灯片][17]有助于理解 Pipenv 所做的以及解决的问题。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/why-python-devs-should-use-pipenv
|
||||
|
||||
作者:[Lacey Williams Henschel][a]
|
||||
译者:[MjSeven](https://github.com/MjSeven)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/laceynwilliams
|
||||
[1]:https://opensource.com/users/jefftriplett
|
||||
[2]:https://packaging.python.org/tutorials/managing-dependencies/#managing-dependencies
|
||||
[3]:http://peak.telecommunity.com/DevCenter/EasyInstall
|
||||
[4]:https://packaging.python.org/tutorials/installing-packages/#use-pip-for-installing
|
||||
[5]:https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments
|
||||
[6]:https://virtualenv.pypa.io/en/stable/
|
||||
[7]:https://docs.python.org/3/library/venv.html
|
||||
[8]:https://virtualenvwrapper.readthedocs.io/en/latest/
|
||||
[9]:https://github.com/pyenv/pyenv
|
||||
[10]:https://github.com/pyenv/pyenv-virtualenv
|
||||
[11]:https://github.com/pyenv/pyenv-virtualenvwrapper
|
||||
[12]:https://github.com/pypa/pipfile
|
||||
[13]:https://docs.pipenv.org/
|
||||
[14]:https://packaging.python.org/tutorials/managing-dependencies/
|
||||
[15]:https://docs.pipenv.org/basics/
|
||||
[16]:https://www.pytennessee.org/schedule/presentation/158/
|
||||
[17]:https://speakerdeck.com/kennethreitz/the-future-of-python-dependency-management
|
Loading…
Reference in New Issue
Block a user