Fail to use pip in Python 3.4 - python

I used Anaconda to install Python 3.4 under Windows 8. At first, everything is fine, and later the system told me that I need to use pip install pip --upgrade to update pip. After I did this, I got some error information on the screen and then pip can no longer be used.
Now when I try to install some packages using pip, there would be some error information:
C:\Users\E440>pip
Traceback (most recent call last):
File "E:\Program Files\Annaconda\lib\runpy.py", line 170, in _run_module_as_ma
in
"__main__", mod_spec)
File "E:\Program Files\Annaconda\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:\Program Files\Annaconda\Scripts\pip.exe\__main__.py", line 5, in <mod
ule>
ImportError: No module named 'pip'
I tried several methods, but still can't fix it. Any suggestions?

You are trying to import pip from your python program; as pip is a linux command, not a python module, this will fail to import the correct program:
import pip
Instead, call it from your bash (linux interpreter):
bash-3.2$ pip install module

Related

Trouble downloading Python modules

I was making a Tetris game and at the top of the Python code, I put in import pygame, since that was the thing I was thinking of doing and the thing I thought I could only do. My game was complete, the terminal was open, and I ran the code. The terminal gives an error:
Traceback (most recent call last):
File "[removed for safety]", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
So I tried pip installing it with the command pip install pygame, but it just returns a similar error:
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python34\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python34\lib\site-packages\pip\__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named 'typing'
I was using
VSCode, with Python version 3.10.5, 64-bit.
First of all you can uninstall python 3.4 from your system, with this link then you can reinstall python from from the python.org website. Then hopefully pip install pygame would work. Or, if pygame is installed run pip uninstall pygame then pip install pygame
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
Python34 is mentioned in the error code, which indicates that the terminal runtime retrieves python3.4 instead of 3.10 you mentioned.
This indicates that there are multiple versions of Python in your environment.
You can manually select the Python interpreter by using shortcut "ctrl+shift+P" and typing "python: select interpreter" or click this icon to change the interpreter:
After choosing the correct interpreter, you can use command pip install pygame to install python package at the correct python-lib.

no module named 'pip' on windows while installing openpyxl

I am install a third party module for the first time.
I am on python 3.10. I have download the openpyxl and extracted the zip folder into:
D:\Users\XXXX\AppData\Local\Programs\Python\Python310\Lib
Then I went to:
D:\Users\XXXX\AppData\Local\Programs\Python\Python310\Scripts
Typed cmd on the address bar and then typed pip install openpyxl.
This is the message returned:
D:\Users\XXXX\AppData\Local\Programs\Python\Python310\Scripts>pip install openpyxl
Traceback (most recent call last):
File "D:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Users\XXXX\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
That's because pip is an Alias. The true command is indeed pip3 (or pip2 depending on what Python version you're using). For Ubuntu, there is an useful tool called python3-is-python which creates this alias. Try looking if this also exists for Windows!
Also, make sure you are running the cmd as administrator. It is very common for Windows to not be able to see those commands.

Whenever I want to use pip I get a ModuleNotFoundError

Whenever I type 'pip' into commandline I get:
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python39\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
I already tried to update 'pip' with using c:\python39\python.exe -m pip install --upgrade pip but there I get:
c:\python39\python.exe: No module named pip
If I replace 'pip' with 'pip3' the same thing happens.
Here is a screenshot of the path variable in system environment variables which shows that pip and python are in the path variable.
Does anyone have ideas for me to fix this error so I can continue programming my python programs.
you can try pip3 instead of pip

Why does my pip install requests giving me an error when i install it?

I tried installing requests with "pip install requests" but it shows this
Traceback (most recent call last):
File "c:\users\me\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\me\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\me\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable
I am on windows 10
That may happens because you don't have proper set PATH of pip in your current machine, instead of use pip install ... you need to specify the python (may vary depending of your python version python3 or python) path and add the -m flag to specify the module that you want to use. in this case pip
try
python -m pip install requests

Pip error when using "pip install ..."

Using OSX El Capitan. Just installed a bunch of pip module and was following a few online tutorials, must have broken something as now I get the following error whenever I try to use pip (although python seems to run fine).
$ pip install pandas
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2837, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 451, in _build_master
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 639, in resolve
pkg_resources.DistributionNotFound: pip==1.5.6
Any helping fixing would be much appreciated.
Thanks.
Reinstall using easy_install. Close the terminal and reopen. Pip should now work.
Try updating pip first by typing pip install -U pip and the try pip install pandas. I myself use Anaconda/Miniconda. Most of the packages are well handled and the dependencies are taken care of as well by the conda package manager.

Categories