简体   繁体   English

如何查看已安装的 Python 包

[英]How to view installed Python packages

I'm using Sublime Text 3 and want to use the dropbox package.我正在使用 Sublime Text 3 并想使用 dropbox 包。 My plan was to download the package using the command prompt and then copy/paste the package into Sublime's installed packages folder.我的计划是使用命令提示符下载包,然后将包复制/粘贴到 Sublime 的已安装包文件夹中。

At the command prompt I typed this code to install dropbox:在命令提示符下,我输入了以下代码来安装 dropbox:

C:\Python\Scripts\pip install dropbox

The output contained a lot of "stuff" but towards the end is:输出包含很多“东西”,但最后是:

Successfully installed certifi-2019.11.28 chardet-3.0.4 dropbox-9.4.0 idna-2.8 requests-2.22.0 urllib3-1.25.7

So it appears to have installed successfully but I can't see any of the mentioned packages in the C:\\Python\\Lib folder.所以它似乎已成功安装,但我在 C:\\Python\\Lib 文件夹中看不到任何提到的包。 Is this not where the packages are kept?这不是存放包裹的地方吗?

pip list will show you installed packages in your environment. pip list将显示您环境中已安装的软件包。

Sublime is a text editor, not an IDE, and therefore does have this feature built in. I'm unaware of extensions that offer similar functionality. Sublime 是一个文本编辑器,而不是 IDE,因此内置了此功能。我不知道提供类似功能的扩展。 Your interpreter will determine where to check for packages when the script is ran, not Sublime.您的解释器将决定在运行脚本时检查包的位置,而不是 Sublime。

From your command-line prompt:从您的命令行提示符:

>> pip3 install dropbox
>> pip3 list # alternatively, pip3 show dropbox
...
dropbox                  9.4.0
...
>> python3 path/to/my/dropbox/using/script.py

pip3 show <package_name> will list information about the package including where it is located. pip3 show <package_name>将列出有关包的信息,包括它所在的位置。

Installed packages are kept in this directory: C:\\Python\\Lib\\site-packages安装的包保存在这个目录中: C:\\Python\\Lib\\site-packages

There is a pip command called list .有一个名为list的 pip 命令。 Use this command to see all packages you have installed.使用此命令查看您已安装的所有软件包。 There are also some options to use along with this command.还有一些选项可以与此命令一起使用。 See the " pip list documentation for more information.有关更多信息,请参阅“ pip list文档。

If the package has been installed elsewhere, you can find the installation location using the show your_package command.如果软件包已安装在其他地方,您可以使用show your_package命令找到安装位置。 This command will show all information about the installed package.此命令将显示有关已安装软件包的所有信息。

Example:例子:

pip show dropbox

Output:输出:

Name: dropbox
Version: 9.4.0
Summary: Official Dropbox API Client
Home-page: http://www.dropbox.com/developers
Author: Dropbox
Author-email: dev-platform@dropbox.com
License: MIT License
Location: c:\users\jean extreme\appdata\local\programs\python\python36\lib\site-packages
Requires: six, requests
Required-by:

Try importing dropbox to find out if it works:尝试导入 dropbox 以查看它是否有效:

import dropbox
print("It works :)")

您可以使用pip listpip list > requirements.txt并手动处理该文件以生成对无虚拟环境的需求文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM