问题
I'm using Python 3.6 through Spyder in Anaconda3. I have both the Anaconda installation and a "clean" python installation.
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.
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?
回答1:
As you can see in this post there is some difference between pip
and conda
.
Using Anaconda
environment you should use the conda
command to install you library, package, etc..
回答2:
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 :
- Open you anaconda navigator
- Go to "Environments"
- Click on the button create. Here by the way you can choose you python version
Then to install your lib you can use your 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
You can also do it in your windows console (cmd), I prefer this way (more trust and you can see what's going on) :
- Open you console
conda activate yourEnvName
conda install -n yourEnvName yourLib
- Only if your conda install did not find your lib do
pip install yourLib
- At the end
conda deactivate
/!\ If you are using this way, close your Anaconda GUI while you are doing this
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.
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
回答3:
If you are using Spyder IDE easiest procedure which i found to install PIP is -:
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:
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.
Step 2-: Now in Step 2 Once you’ve confirmed that Python is correctly installed, you can proceed with installing Pip.
Download get-pip.py https://bootstrap.pypa.io/get-pip.py to 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:
pip -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
回答4:
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.
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.
Hope that helps...
来源:https://stackoverflow.com/questions/50963625/pip-install-in-spyder