Spyder, clean Win installation, ver. 4.2.3 - pip gives message "No module named pip" - python-3.x

I have Spyder, clean Win10 installation, ver. 4.2.3.
When I run command pip, it gives message:
Note: you may need to restart the kernel to use updated packages.
C:\Users\UserName\AppData\Local\Programs\Spyder\Python\python.exe: No module named pip
I restarted Spyder, Win10, nothing helps.
How to fix it?
Thanks.

(Spyder maintainer here) We don't provide pip in our Windows app to prevent people breaking Spyder by installing any kind of packages with it.
The best way to use other packages that don't come with our app is to install Miniconda, create a conda environment after that with the packages you want to use and spyder-kernels, and finally connect Spyder to that env.

If you have python 3.4+ then pip should be installed with python.
To check that, you can run
pip help
in your windows command line.
However, if it isn't the case then download the get-pip.py file and run
python get-pip.py
and the pip installation should start. You can use pip help to verify this.
Another source of the problem might be that pip isn't listed in your PATH variables and thus isn't recognized by your command line.

Related

Conda vs. pip under Spyder

I have a 2-part question about conda vs. pip virtual environments. I found great information on the answers What is the difference between pip and conda? and Does Conda replace the need for virtualenv? but still have something unclear.
I have a given python project (say PR) that I need to install and further develop on a linux server (say S) where python is installed with anaconda. Now, the usage/installation instructions of PR tell me to use python to create virtual environment and pip to install all packages. That is,
python3 -m venv PR
pip install --editable . (the dot included at the end)
According to "pip install --editable ./" vs "python setup.py develop" the latter reads the file setup.py (included in PR) which contains a function setup(...) with option install_requires listing all the required packages and installs them automatically. I have tested this on my own computer (which does not have conda) and it works fine. At least no error messages.
Now I need to further develop PR on S. My question Part 1: can I use conda instead of pip to create and update virtual environment? If yes, what would be the conda command replacing pip install --editable . ? I'm positive I will later need to install other packages as well. I'm worried about conflicts between conda/pip.
On S, I have Spyder and no other python IDEs. I have never used Spyder but I'm very familiar with PyCharm (Windows) and VS Code (Linux) so I assume debugging with Spyder will be similar to those. My question Part 2 (tied to Part 1): if I have to use pip to install packages, does Spyder see those? Or can it only see conda-installed packages?
(Edit/update): Thank you Carlos for comments. I continue my question:
I created and activated the virtual environment (VE) with conda
conda create PR_venv
conda activate PR_venv
Installed pip with
conda install pip
(this upgraded pip and installed several other packages too, including newer version of python). Installed PR and its required packages with pip
pip install -e .
Now, if I run the PR package inside this active VE interactively from the terminal, everything works fine. I would like to do the same from within spyder, to get the IDE debugging abilities in my hand.
When I start spyder, open a python file to be run, click "Run" button, it crashes in the import statements.
Spyder cannot see the installed packages. It can see only the local package PR but none of the packages installed by pip for this VE.
I am not sure what is the correct question here; I'm confused how are conda VEs related to spyder/jupyter/ipython ? I cannot find information in the conda documents about this.
I cannot find from spyder documents anything about VEs. Do I have to somehow re-install the packages (how?) inside Spyder? It seems pointless because the packages are installed already.
(Edit/Update 2): The information on https://docs.spyder-ide.org/current/installation.html makes me even more confused: Spyder is presented as both a stand-alone program and as a python package. So do I have to re-install Spyder inside the VE(?!) with
conda activate PR_venv
conda install spyder
Any clarification would be appreciated. I have always thought that the IDEs are stand-alone programs and that's it. This Spyder setup twists my brains into pretzel.
(Spyder maintainer here) About your questions:
can I use conda instead of pip to create and update virtual environment?
Yes, you can. Please see here to learn about the functionality offered by conda for managing environments.
If yes, what would be the conda command replacing pip install --editable . ?
Conda doesn't offer a good replacement for that command. However, you can still use it in a conda environment, as long as all you've installed all your package dependencies with conda before running it. That would avoid mixing conda and pip packages, which usually leads to really bad results.
if I have to use pip to install packages, does Spyder see those? Or can it only see conda-installed packages?
Spyder can work with pip and conda packages without problems. Just make sure of not mixing them (as I said above) and you'll be fine. In addition, please read our documentation to learn how to connect a local Spyder instance to a remote server.
Part 1: yes I can use conda to create VE and pip to install packages
conda create PR_venv
conda activate PR_venv
conda install pip
pip install --editable .
conda list
The last line shows which packages are installed by conda and which by pip (shown as pypi)
Part 2: spyder by default cannot see the packages. Need to do two things:
conda install spyder-kernels
Open Spyder and Tools > Preferences > Python Interpreter > Use the following interpreter > [full path to VE python command]
Restart Spyder. Now it can see the packages.
(Edit:) this link is great: https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder

How to fix EnvironmentError when installing modules using pip?

When trying to install requests or literally anything using pip it'll collect the option and then give me this ERROR every time. I can't use pip to install anything.
C:\Users\evand>pip3 install requests
Collecting requests
ERROR: Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: path/to/ca-bundle.crt
Version of pip:
C:\Users\evand>pip --version
pip 19.2.3 from c:\users\evand\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)
Version of Python:
C:\Users\evand>py --version
Python 3.8.3
Current Environment Variables (If this is related at all)
I have also tried the 'Repair' option using the Python Installer as well as uninstalling then reinstalling as a custom installation with 'Add to PATH' and the other options. That didn't fix the issue, so I deleted pip along with every module installed on my computer then reinstalled pip. Nada. At this point, I can no longer program with this computer because I cannot import any module in any of my scripts. I am not sure why this issue suddenly arose. Help would be very much appreciated.
This worked for me:
Uninstalling the pip configuration file in %appdata%/pip/ then 'modifying' python using the python launcher.

Pip on only installs to python27 while i need it to install on python37

I have multiple instances of python in my computer namely python27, python3.6 and python 3.7.
The import module for docx worked daily on python27 until suddenly it stopped working today. I tried installing the module again using pip in windows command line.
It says only installed in python27 directory. But there's an
importError on my script.
I guess I should be high time i transferred into python37 but I can't seem to make pip install into python 3.7
Can someone offer some advice as to the messy situation I'm in?I want to transfer to python3 and install docx in python3
Already checked modules using pip and docx is not there.
You should try setting your command prompt on the version of Python you want the module to install. Then, just use "pip", to install.
This is how you can do this:
Go into File Explorer (hopefully you have windows) and press and hold the shift key, then right click the folder that you want command prompt to look at. In this case, the folder with the version of Python. Then you click on the command prompt selection, and you're golden. Just use "pip install xyz" from there on. Glad to help
- BURAK ILOGLU
for python 3 try below given approaches.
sudo apt-get install python3-pip
this should get you pip3 and you can use pip3 to install packages specific to python3
and also
python3 -m pip install <package name>

Installing packages with pip (Python 3.6)

I can't seem to figure out how to use pip with Python 3.6. I'm really lost and annoyed because it seems so easy. I've tried changing the path, calling for it in CMD prompt and PowerShell, but nothing seems to work.
When I type -m pip install matplotlib, for example, it says "Can't find a default Python."
try this out:
python3 -m pip install <package-name>
I hope this helps.
You can explicitly put the Python path while running virtualenv.
virtualenv --python=\path\to\python path\to\new\virtualenv\
then
source testenv/bin/activate
You can also adjust the default python version if you have multiple versions using py.exe on Windows using:
py -3
If I understand correct you are using windows. In that case, make sure that you have definend python path in Environment Variables and then make sure that you have installed pip in your system, for that check with this How do I install pip on Windows? here is good tut on how to do that. After that if you still can't use pip install <package-name> in cmd make sure that you have no restrictions on your proxy, if you have, then you could try to create pip.ini file wich would bypass you'r proxy settings, I have it like this:
Set path:
C:\Users\userName\pip # here create pip catalog
Then create pip.ini file inside pip catalog.
Then create configs:
[global]
strict-ssl=false
always-auth=false
proxy=http://proxyOfYoursUrl:8080/
trusted-host=pypi.python.org
This should help using pip thru cmd.

Python 3.5.2 Windows x86-64 web-based, but installer not installing pip

I am trying to install TensorFlow. The installation instruction for Windows (https://www.tensorflow.org/install/install_windows) have as first step to install Python 3.5.2. And I'm doing the 'TensorFlow with CPU support only'.
Python was successfully installed in my computer as I can run it via the Start menu.
However, when I try to do the 2nd step of the installation instructions in order to install TensorFlow, this step says to:
To install TensorFlow, start a terminal. Then issue the appropriate pip3 install command in that terminal. To install the CPU-only version of TensorFlow, enter the following command:
C:\> pip3 install --upgrade tensorflow
But I'm getting an error when I perform the above statement, the error is
'pip' is not recognized as an internal or external command, oprable program or batch file.
I looked at several postings in StackOverflow and tried the commands provided in one of the postings, but I would get the same type of error.
So, how is 'pip3' installed? from what I read, it is supposed to be installed together with the installation, but obviously that did not happen.
How do I install it? I need to install TensorFlow and it seems that it needs to be done via the pip3 installation tool.
Thank you in advance for your help!
Either set the system environment path variable to include the python 3.5.x path in it, or just cd into the correct python folder to run pip3 from there.
The folder in windows 10 should be something like this:
C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python35\Scripts
Open the terminal, cd to that path (change YOUR_USERNAME to the correct user) and then just run the following command:
pip3 install --upgrade tensorflow
and if you want the gpu version:
pip3 install --upgrade tensorflow-gpu
Pip3 is already installed when you install Python, so there is no need to do anything else.

Resources