How to fix EnvironmentError when installing modules using pip? - python-3.x

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.

Related

"pip install requests" is returning "No module named 'requests'" on Python 3.11

I am new to Python and I have recently downloaded Python 3.11. Somehow I managed to download an earlier version of 3.6.X as well, but I have uninstalled the older version and I have installed the requests package using the command "pip install requests".
I am trying to learn web-scraping in Python, but I am having an issue with the requests module not being found.
I have read over many articles stating that the PATH may not be correct (it wasn't but is now), there may be multiple versions installed (that was also true but has now been corrected), or that pip needed to be upgraded.
Nothing has seemed to work to this point.
I did (at one time) have Python 3.6.X installed as well but I uninstalled this version and made sure that my pip install was upgraded to the newest version. I have also made sure the PATH is correct.
I am still having issues when trying to run "pip install requests" and I am getting an error stating "ModuleNotFoundError: no module named 'requests'".
When I run "python3 -m pip list" in my cmd prompt, I can see requests is installed under version 2.28.1.
Is there anything else I am missing that could be causing a compatibility issue?

Unable to Install Jupyter due to legacy-install-error with psutil package

I was previously running into environment inconsistencies after downloading tensorflow with pip in a conda environment, and after several hours of frustration, decided deleting anaconda/miniconda and python and starting from scratch would be my best option to get python working again (The inconsistencies were causing a plethora of issues with loading other modules like numpy, etc).
After downloading Python version 3.9.10 directly from https://www.python.org/downloads/macos/, I wanted to see if I could start using Python again in a Jupyter notebook in VS Code. When I try to run a simple print('hello world') in a python chunk I (unsurprisingly) get the following error:
Jupyter cannot be started. Error attempting to locate jupyter: Running cells with 'Python 3.9.10 64-bit' requires notebook package.
Run the following command to install 'jupyter and notebook' into the Python environment.
Command: 'python -m pip install jupyter notebook -U'
I was pretty much expecting this error, since I knew I had deleted all packages when deleting Anaconda and Python.
However, when I try running python -m pip install jupyter notebook -U in the terminal I ultimately get the following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> psutil
note: This is an issue with the package mentioned above, not pip.
Any help or insight is greatly appreciated! I am on MacOS (M1) if that is useful information.
The problem seems to be with the python3 distribution that comes with MacOSX Command Line Tools. Well, at least that same error was gone after following these steps.
So, to fix the problem I installed python3.9 (I presume you can change 3.9 to your desired version, e.g. 3.8 or 3.10) using Homebrew.
Install Homebrew (to check if it's installed already just type brew --version in the terminal):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install python3.9
brew install python#3.9
Create your virtual environment
python3.9 -m venv myvenv
Activate the virtual environment with source myvenv/bin/activate
Finally, install Jupyter using
(myvenv) pip install jupyter notebook
I have the same problem when installing the Jupyter notebook on MacOS 12.5 M2 chip. It turns out that the error is caused by not having GCC on my mac to run the wheel for installing the psutil package because for some reason I removed my XCode from my Mac. So I installed XCode from AppStore and opened XCode after the installation to agree to its terms and conditions. After Xcode went through the setup process I tried pip install jupyter again and it worked well.
In my case, I just opened the XCode, accept the terms and the installation proposed, and tried to install the jupyter again and it worked!
It seems to be very particular about the version of python installed. I set up a fresh installation on a new box this morning and put 3.11 on there. pip install jupyterlabs gave me the same error as you got. I then uninstalled python and installed an earlier version, and now it works.
PS the older version that worked for me is 3.10.8

Error installing eth-brownie with pipx: "No Python at: <Location of Old Python Installation>"

I'm trying to install eth-brownie. Followed the Brownie documentation and installed pipx, then ran pipx ensurepath. I was originally using Python 3.10 but couldn't install it, found that this was pretty common and the best fix was to downgrade to 3.9.
After uninstalling 3.10 and installing 3.9, I ran everything again. When I run pipx install eth-brownie, I get the following error:
C:\Users\garri>pipx install eth-brownie
No Python at 'C:\Users\garri\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe'
Fatal error from pip prevented installation. Full pip output in file:
C:\Users\garri\.local\pipx\logs\cmd_2022-03-28_13.40.53_pip_errors.log
Error installing eth-brownie.
I removed Python 3.10 from Path and python --version returns 3.9.12 as expected. I'm at a loss, as I feel like I've tried everything. Any help would be greatly appreciated.
This is basically a pipx cache issue. You have to delete the following folder to remove pipx related cached files.
C:\Users\<username>\.local\pipx

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

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.

can't install pip module smtpd-tls

I am trying to set up a debugging server for testing email logging and I encountered an issue with smtpd module. It was not installed and I can not pip install with with cli or add the package in Pycharm ui. From my understanding of the error it thinks my python version is less than 2.7 but I have confirmed that for this venv I am in 3.7.0. I cannot view the install log because it is a temp file and whe I go to that directory there is no such file.
Any ideas?
This is a known bug in smtpd-tls. Unless you can get the author to update the package, you cannot install smtpd-tls in Python 3.

Resources