Python 在 Spyder 中安装 Pip
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50963625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pip install in Spyder
提问by Martin
I'm using Python 3.6 through Spyder in Anaconda3. I have both the Anaconda installation and a "clean" python installation.
我在 Anaconda3 中通过 Spyder 使用 Python 3.6。我有 Anaconda 安装和“干净”的 python 安装。
Before I installed the "clean" python, when I ran the Python -V
command in cmd I got the following version description Python 3.6.5 :: Anaconda, Inc.
Now when I run the command it just says Python 3.6.5.
and the pip list
is a whole lot shorter.
之前我安装的是“干净”的蟒蛇,当我跑Python -V
在cmd命令我得到了以下版本的描述Python 3.6.5 :: Anaconda, Inc.
现在,当我运行命令它只是说Python 3.6.5.
和pip list
是一大堆短。
When ever I open Spyder and find some package that I don't have... how would I go about installing said package?
If I just open cmd and write pip install ...
it will install in the "clean" python directory.
How do I tell it to connect to Spyder?
当我打开 Spyder 并找到一些我没有的软件包时……我将如何安装所述软件包?如果我只是打开 cmd 并写入pip install ...
它将安装在“干净”的python目录中。我如何告诉它连接到 Spyder?
采纳答案by duntel12
回答by Bastienm
I know it's a very late answer, but it may help other people. When you are working with anaconda you can use the basic environement or create a new one (it may be what's you call a "clean" python installation). To do that just do the following :
我知道这是一个很晚的答案,但它可能会帮助其他人。当您使用 anaconda 时,您可以使用基本环境或创建一个新环境(这可能就是您所说的“干净”python 安装)。要做到这一点,只需执行以下操作:
- Open you anaconda navigator
- Go to "Environments"
- Click on the button create. Here by the way you can choose you python version
- 打开你的anaconda导航器
- 转到“环境”
- 点击按钮创建。顺便说一下,您可以选择python版本
Then to install your lib you can use your Anaconda GUI :
然后安装你的库,你可以使用你的 Anaconda GUI:
- Double click on you environment
- On the right side you have all you installed lib. In the list box select "Not installed"
- Look for your lib, check it and click on "apply" on the bottom right
- 双击你的环境
- 在右侧,您已经安装了所有 lib。在列表框中选择“未安装”
- 查找您的库,检查它并单击右下角的“应用”
You can also do it in your windows console (cmd), I prefer this way (more trust and you can see what's going on) :
您也可以在 Windows 控制台 (cmd) 中执行此操作,我更喜欢这种方式(更多信任,您可以看到发生了什么):
- Open you console
conda activate yourEnvName
conda install -n yourEnvName yourLib
- Only ifyour conda install did not find your lib do
pip install yourLib
- At the end
conda deactivate
- 打开你的控制台
conda activate yourEnvName
conda install -n yourEnvName yourLib
- 仅当您的 conda 安装未找到您的 lib 时
pip install yourLib
- 在末尾
conda deactivate
/!\ If you are using this way, close your Anaconda GUI while you are doing this
/!\ 如果您使用这种方式,请在执行此操作时关闭 Anaconda GUI
If you want you can find your environement(s) in (on Windows) C:\Users\XxUserNamexX\AppData\Local\Continuum\anaconda3\envs. Each folder will contains the library for the named environement.
如果你愿意,你可以在(在 Windows 上)C:\Users\XxUserNamexX\AppData\Local\Continuum\anaconda3\envs 中找到你的环境。每个文件夹将包含命名环境的库。
Hope it will be helpfull
希望它会有所帮助
PS : Note that it is important to launch spyder through the Anaconda GUI if you want Spyder to find your lib
PS:请注意,如果您希望 Spyder 找到您的库,请务必通过 Anaconda GUI 启动 spyder
回答by Sunny Gupta
If you are using Spyder IDE easiest procedure which i found to install PIP is -:
如果您使用的是 Spyder IDE,我发现安装 PIP 的最简单程序是 -:
Step 1- Check if Python is installed correctly. The simplest way to test for a Python installation on your Windows server is to open a command prompt (click on the Windows icon and type cmd, then click on the command prompt icon). Once a command prompt window opens, type python and press Enter. If Python is installed correctly, you should see output similar to what is shown below:
步骤 1- 检查 Python 是否安装正确。在 Windows 服务器上测试 Python 安装的最简单方法是打开命令提示符(单击 Windows 图标并键入 cmd,然后单击命令提示符图标)。命令提示符窗口打开后,键入 python 并按 Enter。如果 Python 安装正确,您应该会看到类似如下所示的输出:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 输入“help”、“copyright”、“credits”或“license”想要查询更多的信息。
Step 2-: Now in Step 2 Once you've confirmed that Python is correctly installed, you can proceed with installing Pip.
步骤 2-:现在在步骤 2 一旦您确认 Python 已正确安装,您就可以继续安装 Pip。
Download get-pip.py https://bootstrap.pypa.io/get-pip.pyto a folder on your computer. Open a command prompt and navigate to the folder containing get-pip.py. Run the following command: python get-pip.py Pip is now installed! You can verify that Pip was installed correctly by opening a command prompt and entering the following command:
将 get-pip.py https://bootstrap.pypa.io/get-pip.py下载 到您计算机上的文件夹中。打开命令提示符并导航到包含 get-pip.py 的文件夹。运行以下命令: python get-pip.py Pip 现已安装!您可以通过打开命令提示符并输入以下命令来验证 Pip 是否已正确安装:
pip -V
点-V
You should see output similar to the following:
您应该会看到类似于以下内容的输出:
pip 18.0 from c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)enter code here
pip 18.0 来自 c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)enter code here
回答by jbartas
There is a pip.exe included in the anaconda/Spyder package which can cleanly add mopdules to Spyder. It's not installed in the windows path by default, probably so it' won't interfere with the "normal" pip in my "normal" python package.
anaconda/Spyder 包中包含一个 pip.exe,它可以干净地将模块添加到 Spyder。默认情况下,它没有安装在 windows 路径中,可能因此它不会干扰我的“普通”python 包中的“普通”pip。
Check "/c/Users/myname/Anaconda3/Scripts/pip.exe". It seems to depend on local DLLs - it did not work (just hung) until I cd'd into it's directory. Once there I used it to install pymongo in the usual way, and the the pymongo package was picked up by Spyder.
检查“/c/Users/myname/Anaconda3/Scripts/pip.exe”。它似乎取决于本地 DLL - 在我进入它的目录之前它没有工作(只是挂起)。在那里我用它以通常的方式安装 pymongo,然后 pymongo 包被 Spyder 接收。
Hope that helps...
希望有帮助...