I have a difficult time using pip to install almost anything. I’m new to coding, so I thought maybe this is something I’ve been doing wrong and have opted out to easy_install to get most of what I needed done, which has generally worked. However, now I’m trying to download the nltk library, and neither is getting the job done.
I tried entering
sudo pip install nltk
but got the following response:
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May 4 00:15:38 2013
Downloading/unpacking nltk
Getting page https://pypi.python.org/simple/nltk/
Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link]/simple/nltk/ when looking for download links for nltk
Getting page [need more reputation to post link]/simple/
Could not fetch URL https://pypi.python. org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link] when looking for download links for nltk
Cannot fetch index base URL [need more reputation to post link]
URLs to search for versions for nltk:
* [need more reputation to post link]
Getting page [need more reputation to post link]
Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm>
Will skip URL [need more reputation to post link] when looking for download links for nltk
Could not find any downloads that satisfy the requirement nltk
No distributions at all found for nltk
Exception information:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1026, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 171, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for nltk
--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it.
Any thoughts on this issue? I’d really appreciate some feedback on how I can either get pip working or something to get around the issue in the meantime.
![]()
asked May 4, 2013 at 4:29
1
I found it sufficient to specify the pypi host as trusted. Example:
pip install --trusted-host pypi.python.org pytest-xdist
pip install --trusted-host pypi.python.org --upgrade pip
This solved the following error:
Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping
Could not find a version that satisfies the requirement pytest-cov (from versions: )
No matching distribution found for pytest-cov
Update April 2018:
To anyone getting the TLSV1_ALERT_PROTOCOL_VERSION error: it has nothing to do with trusted-host/verification issue of the OP or this answer. Rather the TLSV1 error is because your interpreter does not support TLS v1.2, you must upgrade your interpreter. See for example https://news.ycombinator.com/item?id=13539034, http://pyfound.blogspot.ca/2017/01/time-to-upgrade-your-python-tls-v12.html and https://bugs.python.org/issue17128.
Update Feb 2019:
For some it may be sufficient to upgrade pip. If the above error prevents you from doing this, use get-pip.py. E.g. on Linux,
curl https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
More details at https://pip.pypa.io/en/stable/installing/.
answered Aug 12, 2016 at 1:16
![]()
OliverOliver
26.3k9 gold badges66 silver badges96 bronze badges
16
I used pip version 9.0.1 and had the same issue, all the answers above didn’t solve the problem, and I couldn’t install python / pip with brew for other reasons.
Upgrading pip to 9.0.3 solved the problem. And because I couldn’t upgrade pip with pip I downloaded the source and installed it manually.
- Download the correct version of pip from — https://pypi.org/simple/pip/
sudo python3 pip-9.0.3.tar.gz— Install pip
Or you can install newer pip with:
curl https://bootstrap.pypa.io/get-pip.py | python
El Developer
3,3201 gold badge20 silver badges40 bronze badges
answered Apr 12, 2018 at 14:12
![]()
romrom
9998 silver badges16 bronze badges
4
Pypi removed support for TLS versions less than 1.2
You need to re-install Pip, do
curl https://bootstrap.pypa.io/get-pip.py | python
or for global Python:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
BenJi
3534 silver badges11 bronze badges
answered Apr 22, 2018 at 15:10
2
I used pip3 version 9.0.1 and was unable to install any packages recently via the commandpip3 install.
Mac os version: EI Captain 10.11.5.
python version: 3.5
I tried the command:
curl https://bootstrap.pypa.io/get-pip.py | python
It didn’t work for me.
So I uninstalled the older pip and installed the newest version10.0.0 by entering this:
python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3
Now my problem was solved.
If you are using the python2, you can substitute the python3 with python. I hope it also works for you.
By the way, for some rookies like me, you have to enter the code:
sudo -i
to gain the root right 🙂 Good luck!
answered Apr 15, 2018 at 9:28
AachenAachen
4214 silver badges5 bronze badges
2
You’re probably seeing this bug; see also here.
The easiest workaround is to downgrade pip to one that doesn’t use SSL: easy_install pip==1.2.1. This loses you the security benefit of using SSL. The real solution is to use a Python distribution linked to a more recent SSL library.
answered May 4, 2013 at 4:54
![]()
DanicaDanica
28k6 gold badges89 silver badges120 bronze badges
9
Solution — Install any package by marking below hosts trusted
- pypi.python.org
- pypi.org
- files.pythonhosted.org
Temporary solution
pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}
Permanent solution — Update your PIP(problem with version 9.0.1) to latest.
pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org pytest-xdist
python -m pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade pip
answered May 4, 2018 at 17:33
RollerCostaRollerCosta
4,8928 gold badges52 silver badges71 bronze badges
4
Another cause of SSL errors can be a bad system time – certificates won’t validate if it’s too far off from the present.
answered Jan 24, 2014 at 5:07
pidgepidge
7927 silver badges25 bronze badges
1
I tried some of the popular answers, but still could not install any libraries/packages using pip install.
My specific error was 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain using Miniconda for Windows (installer Miniconda3-py37_4.8.3-Windows-x86.exe).
It finally works when I did this:
pip install -r requirements.txt --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org
Specifically, I added this to make it work: --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org
answered Aug 11, 2020 at 17:34
datchungdatchung
3,08624 silver badges23 bronze badges
1
As posted above by blackjar, the below lines worked for me
pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx
You need to give all three --trusted-host options. I was trying with only the first one after looking at the answers but it didn’t work for me like that.
![]()
Blue
22.2k7 gold badges56 silver badges89 bronze badges
answered Jul 31, 2018 at 11:50
abhiabhi
1851 silver badge10 bronze badges
2
I solved a similar problem by adding the --trusted-host pypi.python.org option
answered Aug 9, 2016 at 20:51
![]()
RubenRuben
3315 silver badges13 bronze badges
0
To install any other package I have to use the latest version of pip, since the 9.0.1 has this SSL problem. To upgrade the pip by pip itself, I have to solve this SSL problem first.
To jump out of this endless loop, I find this only way that works for me.
- Find the latest version of pip in this page:
https://pypi.org/simple/pip/ - Download the
.whlfile of the latest version. - Use pip to install the latest pip. (Use your own latest version here)
sudo pip install pip-10.0.1-py2.py3-none-any.whl
Now the pip is the latest version and can install anything.
answered Apr 22, 2018 at 21:12
Jianzhe GuJianzhe Gu
711 silver badge2 bronze badges
macOS Sierra 10.12.6. Wasn’t able to install anything through pip (python installed through homebrew). All the answers above didn’t work.
Eventually, upgrade from python 3.5 to 3.6 worked.
brew update
brew doctor #(in case you see such suggestion by brew)
then follow any additional suggestions by brew, i.e. overwrite link to python.
answered Apr 11, 2018 at 22:21
apatsekinapatsekin
1,4649 silver badges12 bronze badges
1
I had the same problem. I just updated the python from 2.7.0 to 2.7.15. It solves the problem.
You can download here.
answered May 16, 2018 at 8:36
![]()
Günay GültekinGünay Gültekin
4,3168 gold badges32 silver badges36 bronze badges
1
tried
pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install xxx
and finally worked out, not quite understand why the domain pypi.python.org is changed.
answered Jun 21, 2018 at 14:11
You can also use conda to install packages: See http://conda.pydata.org
conda install nltk
The best way to use conda is to download Miniconda, but you can also try
pip install conda
conda init
conda install nltk
answered Jun 14, 2014 at 21:58
2
For me, the latest pip (1.5.6) works fine with the insecure nltk package if you just tell it not to be so picky about security:
pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk
answered Sep 19, 2014 at 18:26
hobshobs
17.8k10 gold badges78 silver badges100 bronze badges
2
If you’re connecting through a proxy, execute export https_proxy=<your_proxy> (on Unix or Git Bash) and then retry installation.
If you’re using Windows cmd, this changes to set https_proxy=<your_proxy>.
answered Jun 23, 2017 at 13:22
lostsoul29lostsoul29
7362 gold badges10 silver badges19 bronze badges
I did the following on Windows 7 to solve this problem.
c:Program FilesPython36Scripts> pip install beautifulsoup4 —trusted-host *
The —trusted-host seems to fix the SSL issue and * means every host.
Of course this does not work because you get other errors since there is no version that satisfies the requirement beautifulsoup4, but I don’t think that issue is related to the general question.
answered Jan 4, 2018 at 22:27
Just uninstall and reinstall pip packages it will workout for you guys.
Mac os version: high Sierra 10.13.6
python version: 3.7
So I uninstalled the older pip and installed the newest version10.0.0 by entering this:
python3 -m pip uninstall pip setuptools
curl https://bootstrap.pypa.io/get-pip.py | python3
Now my problem was solved. If you are using the python2, you can substitute the python3 with python. I hope it also works for you.
answered Sep 25, 2018 at 0:08
Yash PatelYash Patel
791 silver badge5 bronze badges
If it is only about nltk, I once faced similar problem. Try following guide for installation.
Install NLTK
If you are sure it doesn’t work with any other module, you may have problem with different versions of Python installed.
Or Give It a Try to see if it says pip is already installed.:
sudo apt-get install python-pip python-dev build-essential
and see if it works.
answered May 4, 2013 at 7:09
akshaybakshayb
1,1992 gold badges17 silver badges44 bronze badges
I solved this issue with the following steps (on sles 11sp2)
zypper remove pip
easy_install pip=1.2.1
pip install --upgrade scons
Here are the same steps in puppet (which should work on all distros)
package { 'python-pip':
ensure => absent,
}
exec { 'python-pip':
command => '/usr/bin/easy_install pip==1.2.1',
require => Package['python-pip'],
}
package { 'scons':
ensure => latest,
provider => pip,
require => Exec['python-pip'],
}
answered Jul 31, 2014 at 17:02
spuderspuder
16.8k19 gold badges86 silver badges148 bronze badges
I had this with PyCharm and upgrading pip to 10.0.1 broke pip with «‘main’ not found in module» error.
I could solve this problem by installing pip 9.0.3 as seen in some other thread. These are the steps I did:
- Downloaded 9.0.3 version of pip from https://pypi.org/simple/pip/ (since pip couldn’t be used to install it).
- Install pip 9.0.3 from tar.gz
python -m pip install pip-9.0.3.tar.gz
Everything started to work after that.
answered Apr 25, 2018 at 20:33
This video tutorial worked for me:
$ curl https://bootstrap.pypa.io/get-pip.py | python
![]()
Generic Bot
3091 gold badge4 silver badges8 bronze badges
answered Jul 10, 2018 at 21:59
![]()
Try installing xcode and then using homebrew to install pipenv using «brew install pipenv».
answered Jun 14, 2021 at 15:23
1
При попытке установки практически любой библиотеки через pip возникает ошибка:
На примере библиотеки requests:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A760>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A910>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499A9E8>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AAC0>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AB98>: Failed to establish a new
connection: [Errno 11002] getaddrinfo failed')': /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.2
8.1-py3-none-any.whl (Caused by NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0499AC70>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
Однако, например с библиотекой aiogram всё работает исправно 🙂 Так же ошибка начала появляться только сегодня, вчера я мог устанавливать все библиотеки без труда через терминал
Как исправить эту ошибку для установки нужных мне библиотек?
Важно: я использую интерпретатор PyCharm, устанавливаю библиотеки через него, однако при установке через cmd происходит аналогичная ситуация и та же ошибка
Python is installed in a local directory.
My directory tree looks like this:
(local directory)/site-packages/toolkit/interface.py
My code is in here:
(local directory)/site-packages/toolkit/examples/mountain.py
To run the example, I write python mountain.py, and in the code I have:
from toolkit.interface import interface
And I get the error:
Traceback (most recent call last):
File "mountain.py", line 28, in ?
from toolkit.interface import interface
ImportError: No module named toolkit.interface
I have already checked sys.path and there I have the directory /site-packages. Also, I have the file __init__.py.bin in the toolkit folder to indicate to Python that this is a package. I also have a __init__.py.bin in the examples directory.
I do not know why Python cannot find the file when it is in sys.path. Any ideas? Can it be a permissions problem? Do I need some execution permission?
![]()
alex
6,3129 gold badges50 silver badges102 bronze badges
asked Dec 3, 2008 at 21:26
7
Based on your comments to orip’s post, I guess this is what happened:
- You edited
__init__.pyon windows. - The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
- You used WinSCP to copy the file to your unix box.
- WinSCP thought: «This has something that’s not basic text; I’ll put a .bin extension to indicate binary data.»
- The missing
__init__.py(now called__init__.py.bin) means python doesn’t understand toolkit as a package. - You create
__init__.pyin the appropriate directory and everything works… ?
answered Dec 4, 2008 at 0:17
John FouhyJohn Fouhy
40.5k19 gold badges62 silver badges77 bronze badges
8
Does
(local directory)/site-packages/toolkit
have a __init__.py?
To make import walk through your directories every directory must have a __init__.py file.
answered Dec 3, 2008 at 21:50
![]()
igorgueigorgue
17.6k13 gold badges37 silver badges52 bronze badges
2
I ran into something very similar when I did this exercise in LPTHW; I could never get Python to recognise that I had files in the directory I was calling from. But I was able to get it to work in the end. What I did, and what I recommend, is to try this:
(NOTE: From your initial post, I am assuming you are using an *NIX-based machine and are running things from the command line, so this advice is tailored to that. Since I run Ubuntu, this is what I did)
-
Change directory (cd) to the directory above the directory where your files are. In this case, you’re trying to run the
mountain.pyfile, and trying to call thetoolkit.interface.pymodule, which are in separate directories. In this case, you would go to the directory that contains paths to both those files (or in other words, the closest directory that the paths of both those files share). Which in this case is thetoolkitdirectory. -
When you are in the
toolkitdirectory, enter this line of code on your command line:export PYTHONPATH=.This sets your PYTHONPATH to «.», which basically means that your PYTHONPATH will now look for any called files within the directory you are currently in, (and more to the point, in the sub-directory branches of the directory you are in. So it doesn’t just look in your current directory, but in all the directories that are in your current directory).
-
After you’ve set your PYTHONPATH in the step above, run your module from your current directory (the
toolkitdirectory). Python should now find and load the modules you specified.
![]()
user
3,9365 gold badges17 silver badges34 bronze badges
answered Apr 22, 2014 at 3:52
SpecteraceSpecterace
9956 silver badges7 bronze badges
4
On *nix, also make sure that PYTHONPATH is configured correctly, especially that it has this format:
.:/usr/local/lib/python
(Mind the .: at the beginning, so that it can search on the current directory, too.)
It may also be in other locations, depending on the version:
.:/usr/lib/python
.:/usr/lib/python2.6
.:/usr/lib/python2.7 and etc.
![]()
answered Mar 4, 2011 at 21:14
RenaudRenaud
15.7k6 gold badges79 silver badges78 bronze badges
6
You are reading this answer says that your __init__.py is in the right place, you have installed all the dependencies and you are still getting the ImportError.
I was facing a similar issue except that my program would run fine when ran using PyCharm but the above error when I would run it from the terminal. After digging further, I found out that PYTHONPATH didn’t have the entry for the project directory. So, I set PYTHONPATH per Import statement works on PyCharm but not from terminal:
export PYTHONPATH=$PYTHONPATH:`pwd` (OR your project root directory)
There’s another way to do this using sys.path as:
import sys
sys.path.insert(0,'<project directory>') OR
sys.path.append('<project directory>')
You can use insert/append based on the order in which you want your project to be searched.
![]()
jww
94.9k88 gold badges395 silver badges860 bronze badges
answered Feb 8, 2019 at 16:57
![]()
avpavp
2,71228 silver badges33 bronze badges
4
Using PyCharm (part of the JetBrains suite) you need to define your script directory as Source:
Right Click > Mark Directory as > Sources Root
answered Jan 4, 2017 at 17:53
![]()
MonoThreadedMonoThreaded
11.1k11 gold badges68 silver badges100 bronze badges
2
For me, it was something really stupid. I installed the library using pip3 install but was running my program as python program.py as opposed to python3 program.py.
![]()
answered Aug 22, 2019 at 16:02
![]()
kevkev
2,6413 gold badges21 silver badges45 bronze badges
1
I solved my own problem, and I will write a summary of the things that were wrong and the solution:
The file needs to be called exactly __init__.py. If the extension is different such as in my case .py.bin then Python cannot move through the directories and then it cannot find the modules. To edit the files you need to use a Linux editor, such as vi or nano. If you use a Windows editor this will write some hidden characters.
Another problem that was affecting it was that I had another Python version installed by the root, so if someone is working with a local installation of python, be sure that the Python installation that is running the programs is the local Python. To check this, just do which python, and see if the executable is the one that is in your local directory. If not, change the path, but be sure that the local Python directory is before than the other Python.
![]()
answered Dec 4, 2008 at 1:11
EduardoEduardo
19.4k22 gold badges63 silver badges73 bronze badges
3
To mark a directory as a package you need a file named __init__.py, does this help?
answered Dec 3, 2008 at 21:31
oriporip
71.9k21 gold badges118 silver badges147 bronze badges
8
an easy solution is to install the module using python -m pip install <library-name> instead of pip install <library-name>
you may use sudo in case of admin restrictions
answered Sep 18, 2017 at 15:30
![]()
Badr BellajBadr Bellaj
10.5k2 gold badges39 silver badges39 bronze badges
3
To all those who still have this issue. I believe Pycharm gets confused with imports. For me, when i write ‘from namespace import something’, the previous line gets underlined in red, signaling that there is an error, but works. However »from .namespace import something’ doesn’t get underlined, but also doesn’t work.
Try
try:
from namespace import something
except NameError:
from .namespace import something
answered May 11, 2019 at 19:34
AKJAKJ
8522 gold badges13 silver badges18 bronze badges
1
Yup. You need the directory to contain the __init__.py file, which is the file that initializes the package. Here, have a look at this.
The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
answered Jan 7, 2009 at 14:22
miyamiya
1,0591 gold badge11 silver badges20 bronze badges
If you have tried all methods provided above but failed, maybe your module has the same name as a built-in module. Or, a module with the same name existing in a folder that has a high priority in sys.path than your module’s.
To debug, say your from foo.bar import baz complaints ImportError: No module named bar. Changing to import foo; print foo, which will show the path of foo. Is it what you expect?
If not, Either rename foo or use absolute imports.
answered May 2, 2017 at 6:41
liushuaikobeliushuaikobe
2,1221 gold badge23 silver badges26 bronze badges
1
- You must have the file __ init__.py in the same directory where it’s the file that you are importing.
- You can not try to import a file that has the same name and be a file from 2 folders configured on the PYTHONPATH.
eg:
/etc/environment
PYTHONPATH=$PYTHONPATH:/opt/folder1:/opt/folder2
/opt/folder1/foo
/opt/folder2/foo
And, if you are trying to import foo file, python will not know which one you want.
from foo import … >>> importerror: no module named foo
answered Jan 9, 2014 at 19:45
![]()
Iasmini GomesIasmini Gomes
6571 gold badge8 silver badges14 bronze badges
0
My two cents:

Spit:
Traceback (most recent call last):
File "bashbash.py", line 454, in main
import bosh
File "Wrye Bash Launcher.pyw", line 63, in load_module
mod = imp.load_source(fullname,filename+ext,fp)
File "bashbosh.py", line 69, in <module>
from game.oblivion.RecordGroups import MobWorlds, MobDials, MobICells,
ImportError: No module named RecordGroups
This confused the hell out of me — went through posts and posts suggesting ugly syspath hacks (as you see my __init__.py were all there). Well turns out that game/oblivion.py and game/oblivion was confusing python
which spit out the rather unhelpful «No module named RecordGroups». I’d be interested in a workaround and/or links documenting this (same name) behavior -> EDIT (2017.01.24) — have a look at What If I Have a Module and a Package With The Same Name? Interestingly normally packages take precedence but apparently our launcher violates this.
EDIT (2015.01.17): I did not mention we use a custom launcher dissected here.
answered Sep 6, 2014 at 11:17
Mr_and_Mrs_DMr_and_Mrs_D
31.1k37 gold badges175 silver badges355 bronze badges
2
Fixed my issue by writing print (sys.path) and found out that python was using out of date packages despite a clean install. Deleting these made python automatically use the correct packages.
answered Jul 21, 2016 at 18:51
![]()
dukevindukevin
22k36 gold badges80 silver badges110 bronze badges
In my case, because I’m using PyCharm and PyCharm create a ‘venv’ for every project in project folder, but it is only a mini env of python. Although you have installed the libraries you need in Python, but in your custom project ‘venv’, it is not available. This is the real reason of ‘ImportError: No module named xxxxxx’ occurred in PyCharm.
To resolve this issue, you must add libraries to your project custom env by these steps:
- In PyCharm, from menu ‘File’->Settings
- In Settings dialog, Project: XXXProject->Project Interpreter
- Click «Add» button, it will show you ‘Available Packages’ dialog
- Search your library, click ‘Install Package’
- Then, all you needed package will be installed in you project custom ‘venv’ folder.

Enjoy.
answered Feb 18, 2019 at 3:35
![]()
YuanhuiYuanhui
4595 silver badges15 bronze badges
Linux: Imported modules are located in /usr/local/lib/python2.7/dist-packages
If you’re using a module compiled in C, don’t forget to chmod the .so file after sudo setup.py install.
sudo chmod 755 /usr/local/lib/python2.7/dist-packages/*.so
answered May 30, 2014 at 22:50
KrisWebDevKrisWebDev
9,2324 gold badges38 silver badges59 bronze badges
0
In my case, the problem was I was linking to debug python & boost::Python, which requires that the extension be FooLib_d.pyd, not just FooLib.pyd; renaming the file or updating CMakeLists.txt properties fixed the error.
![]()
answered Sep 4, 2013 at 2:52
peter karasevpeter karasev
2,5281 gold badge28 silver badges38 bronze badges
My problem was that I added the directory with the __init__.py file to PYTHONPATH, when actually I needed to add its parent directory.
answered Mar 27, 2018 at 12:41
RichRich
6421 gold badge6 silver badges14 bronze badges
0
If you are using a setup script/utility (e.g. setuptools) to deploy your package, don’t forget to add the respective files/modules to the installer.
When supported, use find_packages() or similar to automatically add new packages to the setup script. This will absolutely save you from a headache, especially if you put your project aside for some time and then add something later on.
import setuptools
setuptools.setup(
name="example-pkg",
version="0.0.1",
author="Example Author",
author_email="author@example.com",
description="A small example package",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
(Example taken from setuptools documentation)
answered Oct 17, 2020 at 11:36
michael-slxmichael-slx
6558 silver badges15 bronze badges
For me, running the file as a module helped.
Instead of
python myapp/app.py
using
python -m myapp.app
It’s not exactly the same but it might be a better approach in some cases.
answered Apr 28, 2022 at 13:59
juanignaciosljuanignaciosl
3,3952 gold badges26 silver badges28 bronze badges
I had the same problem (Python 2.7 Linux), I have found the solution and i would like to share it. In my case i had the structure below:
Booklet
-> __init__.py
-> Booklet.py
-> Question.py
default
-> __init_.py
-> main.py
In ‘main.py’ I had tried unsuccessfully all the combinations bellow:
from Booklet import Question
from Question import Question
from Booklet.Question import Question
from Booklet.Question import *
import Booklet.Question
# and many othet various combinations ...
The solution was much more simple than I thought. I renamed the folder «Booklet» into «booklet» and that’s it. Now Python can import the class Question normally by using in ‘main.py’ the code:
from booklet.Booklet import Booklet
from booklet.Question import Question
from booklet.Question import AnotherClass
From this I can conclude that Package-Names (folders) like ‘booklet’ must start from lower-case, else Python confuses it with Class names and Filenames.
Apparently, this was not your problem, but John Fouhy’s answer is very good and this thread has almost anything that can cause this issue. So, this is one more thing and I hope that maybe this could help others.
answered May 27, 2018 at 23:49
![]()
ioaniatrioaniatr
2774 silver badges15 bronze badges
In linux server try dos2unix script_name
(remove all (if there is any) pyc files with command find . -name '*.pyc' -delete)
and re run in the case if you worked on script on windows
answered Jan 17, 2020 at 15:07
PoliPoli
7710 bronze badges
In my case, I was using sys.path.insert() to import a local module and was getting module not found from a different library. I had to put sys.path.insert() below the imports that reported module not found. I guess the best practice is to put sys.path.insert() at the bottom of your imports.
answered Mar 10, 2020 at 9:55
![]()
I’ve found that changing the name (via GUI) of aliased folders (Mac) can cause issues with loading modules. If the original folder name is changed, remake the symbolic link. I’m unsure how prevalent this behavior may be, but it was frustrating to debug.
answered Feb 17, 2021 at 18:47
![]()
GhotiGhoti
7374 silver badges18 bronze badges
another cause makes this issue
file.py
#!/bin/python
from bs4 import BeautifulSoup
- if your default
pythonispyyhon2
$ file $(which python)
/sbin/python: symbolic link to python2
file.pyneedpython3, for this case(bs4)- you can not execute this module with
python2like this:
$ python file.py
# or
$ file.py
# or
$ file.py # if locate in $PATH
- Tow way to fix this
error,
# should be to make python3 as default by symlink
$ rm $(which python) && ln -s $(which python3) /usr/bin/python
# or use alias
alias python='/usr/bin.../python3'
or change shebang in file.py to
#!/usr/bin/...python3
answered Aug 2, 2022 at 23:05
After just suffering the same issue I found my resolution was to delete all pyc files from my project, it seems like these cached files were somehow causing this error.
Easiest way I found to do this was to navigate to my project folder in Windows explorer and searching for *.pyc, then selecting all (Ctrl+A) and deleting them (Ctrl+X).
Its possible I could have resolved my issues by just deleting the specific pyc file but I never tried this
![]()
sina72
4,8413 gold badges34 silver badges36 bronze badges
answered Aug 8, 2014 at 8:36
![]()
SayseSayse
42.2k14 gold badges77 silver badges142 bronze badges
0
I faced the same problem: Import error. In addition the library’ve been installed 100% correctly. The source of the problem was that on my PC 3 version of python (anaconda packet) have been installed). This is why the library was installed no to the right place. After that I just changed to the proper version of python in the my IDE PyCharm.
answered Dec 5, 2015 at 7:21
![]()
RocketqRocketq
5,00420 gold badges75 silver badges122 bronze badges
I had the same error. It was caused by somebody creating a folder in the same folder as my script, the name of which conflicted with a module I was importing from elsewhere. Instead of importing the external module, it looked inside this folder which obviously didn’t contain the expected modules.
answered Dec 13, 2016 at 11:45
![]()
Toivo SäwénToivo Säwén
1,6632 gold badges14 silver badges32 bronze badges
Python is installed in a local directory.
My directory tree looks like this:
(local directory)/site-packages/toolkit/interface.py
My code is in here:
(local directory)/site-packages/toolkit/examples/mountain.py
To run the example, I write python mountain.py, and in the code I have:
from toolkit.interface import interface
And I get the error:
Traceback (most recent call last):
File "mountain.py", line 28, in ?
from toolkit.interface import interface
ImportError: No module named toolkit.interface
I have already checked sys.path and there I have the directory /site-packages. Also, I have the file __init__.py.bin in the toolkit folder to indicate to Python that this is a package. I also have a __init__.py.bin in the examples directory.
I do not know why Python cannot find the file when it is in sys.path. Any ideas? Can it be a permissions problem? Do I need some execution permission?
![]()
alex
6,3129 gold badges50 silver badges102 bronze badges
asked Dec 3, 2008 at 21:26
7
Based on your comments to orip’s post, I guess this is what happened:
- You edited
__init__.pyon windows. - The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
- You used WinSCP to copy the file to your unix box.
- WinSCP thought: «This has something that’s not basic text; I’ll put a .bin extension to indicate binary data.»
- The missing
__init__.py(now called__init__.py.bin) means python doesn’t understand toolkit as a package. - You create
__init__.pyin the appropriate directory and everything works… ?
answered Dec 4, 2008 at 0:17
John FouhyJohn Fouhy
40.5k19 gold badges62 silver badges77 bronze badges
8
Does
(local directory)/site-packages/toolkit
have a __init__.py?
To make import walk through your directories every directory must have a __init__.py file.
answered Dec 3, 2008 at 21:50
![]()
igorgueigorgue
17.6k13 gold badges37 silver badges52 bronze badges
2
I ran into something very similar when I did this exercise in LPTHW; I could never get Python to recognise that I had files in the directory I was calling from. But I was able to get it to work in the end. What I did, and what I recommend, is to try this:
(NOTE: From your initial post, I am assuming you are using an *NIX-based machine and are running things from the command line, so this advice is tailored to that. Since I run Ubuntu, this is what I did)
-
Change directory (cd) to the directory above the directory where your files are. In this case, you’re trying to run the
mountain.pyfile, and trying to call thetoolkit.interface.pymodule, which are in separate directories. In this case, you would go to the directory that contains paths to both those files (or in other words, the closest directory that the paths of both those files share). Which in this case is thetoolkitdirectory. -
When you are in the
toolkitdirectory, enter this line of code on your command line:export PYTHONPATH=.This sets your PYTHONPATH to «.», which basically means that your PYTHONPATH will now look for any called files within the directory you are currently in, (and more to the point, in the sub-directory branches of the directory you are in. So it doesn’t just look in your current directory, but in all the directories that are in your current directory).
-
After you’ve set your PYTHONPATH in the step above, run your module from your current directory (the
toolkitdirectory). Python should now find and load the modules you specified.
![]()
user
3,9365 gold badges17 silver badges34 bronze badges
answered Apr 22, 2014 at 3:52
SpecteraceSpecterace
9956 silver badges7 bronze badges
4
On *nix, also make sure that PYTHONPATH is configured correctly, especially that it has this format:
.:/usr/local/lib/python
(Mind the .: at the beginning, so that it can search on the current directory, too.)
It may also be in other locations, depending on the version:
.:/usr/lib/python
.:/usr/lib/python2.6
.:/usr/lib/python2.7 and etc.
![]()
answered Mar 4, 2011 at 21:14
RenaudRenaud
15.7k6 gold badges79 silver badges78 bronze badges
6
You are reading this answer says that your __init__.py is in the right place, you have installed all the dependencies and you are still getting the ImportError.
I was facing a similar issue except that my program would run fine when ran using PyCharm but the above error when I would run it from the terminal. After digging further, I found out that PYTHONPATH didn’t have the entry for the project directory. So, I set PYTHONPATH per Import statement works on PyCharm but not from terminal:
export PYTHONPATH=$PYTHONPATH:`pwd` (OR your project root directory)
There’s another way to do this using sys.path as:
import sys
sys.path.insert(0,'<project directory>') OR
sys.path.append('<project directory>')
You can use insert/append based on the order in which you want your project to be searched.
![]()
jww
94.9k88 gold badges395 silver badges860 bronze badges
answered Feb 8, 2019 at 16:57
![]()
avpavp
2,71228 silver badges33 bronze badges
4
Using PyCharm (part of the JetBrains suite) you need to define your script directory as Source:
Right Click > Mark Directory as > Sources Root
answered Jan 4, 2017 at 17:53
![]()
MonoThreadedMonoThreaded
11.1k11 gold badges68 silver badges100 bronze badges
2
For me, it was something really stupid. I installed the library using pip3 install but was running my program as python program.py as opposed to python3 program.py.
![]()
answered Aug 22, 2019 at 16:02
![]()
kevkev
2,6413 gold badges21 silver badges45 bronze badges
1
I solved my own problem, and I will write a summary of the things that were wrong and the solution:
The file needs to be called exactly __init__.py. If the extension is different such as in my case .py.bin then Python cannot move through the directories and then it cannot find the modules. To edit the files you need to use a Linux editor, such as vi or nano. If you use a Windows editor this will write some hidden characters.
Another problem that was affecting it was that I had another Python version installed by the root, so if someone is working with a local installation of python, be sure that the Python installation that is running the programs is the local Python. To check this, just do which python, and see if the executable is the one that is in your local directory. If not, change the path, but be sure that the local Python directory is before than the other Python.
![]()
answered Dec 4, 2008 at 1:11
EduardoEduardo
19.4k22 gold badges63 silver badges73 bronze badges
3
To mark a directory as a package you need a file named __init__.py, does this help?
answered Dec 3, 2008 at 21:31
oriporip
71.9k21 gold badges118 silver badges147 bronze badges
8
an easy solution is to install the module using python -m pip install <library-name> instead of pip install <library-name>
you may use sudo in case of admin restrictions
answered Sep 18, 2017 at 15:30
![]()
Badr BellajBadr Bellaj
10.5k2 gold badges39 silver badges39 bronze badges
3
To all those who still have this issue. I believe Pycharm gets confused with imports. For me, when i write ‘from namespace import something’, the previous line gets underlined in red, signaling that there is an error, but works. However »from .namespace import something’ doesn’t get underlined, but also doesn’t work.
Try
try:
from namespace import something
except NameError:
from .namespace import something
answered May 11, 2019 at 19:34
AKJAKJ
8522 gold badges13 silver badges18 bronze badges
1
Yup. You need the directory to contain the __init__.py file, which is the file that initializes the package. Here, have a look at this.
The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
answered Jan 7, 2009 at 14:22
miyamiya
1,0591 gold badge11 silver badges20 bronze badges
If you have tried all methods provided above but failed, maybe your module has the same name as a built-in module. Or, a module with the same name existing in a folder that has a high priority in sys.path than your module’s.
To debug, say your from foo.bar import baz complaints ImportError: No module named bar. Changing to import foo; print foo, which will show the path of foo. Is it what you expect?
If not, Either rename foo or use absolute imports.
answered May 2, 2017 at 6:41
liushuaikobeliushuaikobe
2,1221 gold badge23 silver badges26 bronze badges
1
- You must have the file __ init__.py in the same directory where it’s the file that you are importing.
- You can not try to import a file that has the same name and be a file from 2 folders configured on the PYTHONPATH.
eg:
/etc/environment
PYTHONPATH=$PYTHONPATH:/opt/folder1:/opt/folder2
/opt/folder1/foo
/opt/folder2/foo
And, if you are trying to import foo file, python will not know which one you want.
from foo import … >>> importerror: no module named foo
answered Jan 9, 2014 at 19:45
![]()
Iasmini GomesIasmini Gomes
6571 gold badge8 silver badges14 bronze badges
0
My two cents:

Spit:
Traceback (most recent call last):
File "bashbash.py", line 454, in main
import bosh
File "Wrye Bash Launcher.pyw", line 63, in load_module
mod = imp.load_source(fullname,filename+ext,fp)
File "bashbosh.py", line 69, in <module>
from game.oblivion.RecordGroups import MobWorlds, MobDials, MobICells,
ImportError: No module named RecordGroups
This confused the hell out of me — went through posts and posts suggesting ugly syspath hacks (as you see my __init__.py were all there). Well turns out that game/oblivion.py and game/oblivion was confusing python
which spit out the rather unhelpful «No module named RecordGroups». I’d be interested in a workaround and/or links documenting this (same name) behavior -> EDIT (2017.01.24) — have a look at What If I Have a Module and a Package With The Same Name? Interestingly normally packages take precedence but apparently our launcher violates this.
EDIT (2015.01.17): I did not mention we use a custom launcher dissected here.
answered Sep 6, 2014 at 11:17
Mr_and_Mrs_DMr_and_Mrs_D
31.1k37 gold badges175 silver badges355 bronze badges
2
Fixed my issue by writing print (sys.path) and found out that python was using out of date packages despite a clean install. Deleting these made python automatically use the correct packages.
answered Jul 21, 2016 at 18:51
![]()
dukevindukevin
22k36 gold badges80 silver badges110 bronze badges
In my case, because I’m using PyCharm and PyCharm create a ‘venv’ for every project in project folder, but it is only a mini env of python. Although you have installed the libraries you need in Python, but in your custom project ‘venv’, it is not available. This is the real reason of ‘ImportError: No module named xxxxxx’ occurred in PyCharm.
To resolve this issue, you must add libraries to your project custom env by these steps:
- In PyCharm, from menu ‘File’->Settings
- In Settings dialog, Project: XXXProject->Project Interpreter
- Click «Add» button, it will show you ‘Available Packages’ dialog
- Search your library, click ‘Install Package’
- Then, all you needed package will be installed in you project custom ‘venv’ folder.

Enjoy.
answered Feb 18, 2019 at 3:35
![]()
YuanhuiYuanhui
4595 silver badges15 bronze badges
Linux: Imported modules are located in /usr/local/lib/python2.7/dist-packages
If you’re using a module compiled in C, don’t forget to chmod the .so file after sudo setup.py install.
sudo chmod 755 /usr/local/lib/python2.7/dist-packages/*.so
answered May 30, 2014 at 22:50
KrisWebDevKrisWebDev
9,2324 gold badges38 silver badges59 bronze badges
0
In my case, the problem was I was linking to debug python & boost::Python, which requires that the extension be FooLib_d.pyd, not just FooLib.pyd; renaming the file or updating CMakeLists.txt properties fixed the error.
![]()
answered Sep 4, 2013 at 2:52
peter karasevpeter karasev
2,5281 gold badge28 silver badges38 bronze badges
My problem was that I added the directory with the __init__.py file to PYTHONPATH, when actually I needed to add its parent directory.
answered Mar 27, 2018 at 12:41
RichRich
6421 gold badge6 silver badges14 bronze badges
0
If you are using a setup script/utility (e.g. setuptools) to deploy your package, don’t forget to add the respective files/modules to the installer.
When supported, use find_packages() or similar to automatically add new packages to the setup script. This will absolutely save you from a headache, especially if you put your project aside for some time and then add something later on.
import setuptools
setuptools.setup(
name="example-pkg",
version="0.0.1",
author="Example Author",
author_email="author@example.com",
description="A small example package",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
(Example taken from setuptools documentation)
answered Oct 17, 2020 at 11:36
michael-slxmichael-slx
6558 silver badges15 bronze badges
For me, running the file as a module helped.
Instead of
python myapp/app.py
using
python -m myapp.app
It’s not exactly the same but it might be a better approach in some cases.
answered Apr 28, 2022 at 13:59
juanignaciosljuanignaciosl
3,3952 gold badges26 silver badges28 bronze badges
I had the same problem (Python 2.7 Linux), I have found the solution and i would like to share it. In my case i had the structure below:
Booklet
-> __init__.py
-> Booklet.py
-> Question.py
default
-> __init_.py
-> main.py
In ‘main.py’ I had tried unsuccessfully all the combinations bellow:
from Booklet import Question
from Question import Question
from Booklet.Question import Question
from Booklet.Question import *
import Booklet.Question
# and many othet various combinations ...
The solution was much more simple than I thought. I renamed the folder «Booklet» into «booklet» and that’s it. Now Python can import the class Question normally by using in ‘main.py’ the code:
from booklet.Booklet import Booklet
from booklet.Question import Question
from booklet.Question import AnotherClass
From this I can conclude that Package-Names (folders) like ‘booklet’ must start from lower-case, else Python confuses it with Class names and Filenames.
Apparently, this was not your problem, but John Fouhy’s answer is very good and this thread has almost anything that can cause this issue. So, this is one more thing and I hope that maybe this could help others.
answered May 27, 2018 at 23:49
![]()
ioaniatrioaniatr
2774 silver badges15 bronze badges
In linux server try dos2unix script_name
(remove all (if there is any) pyc files with command find . -name '*.pyc' -delete)
and re run in the case if you worked on script on windows
answered Jan 17, 2020 at 15:07
PoliPoli
7710 bronze badges
In my case, I was using sys.path.insert() to import a local module and was getting module not found from a different library. I had to put sys.path.insert() below the imports that reported module not found. I guess the best practice is to put sys.path.insert() at the bottom of your imports.
answered Mar 10, 2020 at 9:55
![]()
I’ve found that changing the name (via GUI) of aliased folders (Mac) can cause issues with loading modules. If the original folder name is changed, remake the symbolic link. I’m unsure how prevalent this behavior may be, but it was frustrating to debug.
answered Feb 17, 2021 at 18:47
![]()
GhotiGhoti
7374 silver badges18 bronze badges
another cause makes this issue
file.py
#!/bin/python
from bs4 import BeautifulSoup
- if your default
pythonispyyhon2
$ file $(which python)
/sbin/python: symbolic link to python2
file.pyneedpython3, for this case(bs4)- you can not execute this module with
python2like this:
$ python file.py
# or
$ file.py
# or
$ file.py # if locate in $PATH
- Tow way to fix this
error,
# should be to make python3 as default by symlink
$ rm $(which python) && ln -s $(which python3) /usr/bin/python
# or use alias
alias python='/usr/bin.../python3'
or change shebang in file.py to
#!/usr/bin/...python3
answered Aug 2, 2022 at 23:05
After just suffering the same issue I found my resolution was to delete all pyc files from my project, it seems like these cached files were somehow causing this error.
Easiest way I found to do this was to navigate to my project folder in Windows explorer and searching for *.pyc, then selecting all (Ctrl+A) and deleting them (Ctrl+X).
Its possible I could have resolved my issues by just deleting the specific pyc file but I never tried this
![]()
sina72
4,8413 gold badges34 silver badges36 bronze badges
answered Aug 8, 2014 at 8:36
![]()
SayseSayse
42.2k14 gold badges77 silver badges142 bronze badges
0
I faced the same problem: Import error. In addition the library’ve been installed 100% correctly. The source of the problem was that on my PC 3 version of python (anaconda packet) have been installed). This is why the library was installed no to the right place. After that I just changed to the proper version of python in the my IDE PyCharm.
answered Dec 5, 2015 at 7:21
![]()
RocketqRocketq
5,00420 gold badges75 silver badges122 bronze badges
I had the same error. It was caused by somebody creating a folder in the same folder as my script, the name of which conflicted with a module I was importing from elsewhere. Instead of importing the external module, it looked inside this folder which obviously didn’t contain the expected modules.
answered Dec 13, 2016 at 11:45
![]()
Toivo SäwénToivo Säwén
1,6632 gold badges14 silver badges32 bronze badges
При попытке обновить PIP
C:Usersbreik1>python -m pip install —upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org… ne-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Exception:
Traceback (most recent call last):
File «C:Program FilesPython36libshutil.py», line 544, in move
os.rename(src, real_dst)
PermissionError: [WinError 5] Отказано в доступе: ‘c:\program files\python36\lib\site-packages\pip-9.0.1.dist-info\description.rst’ -> ‘C:\Users\breik1\AppData\Local\Temp\pip-lbm43_x3-uninstall\program files\python36\lib\site-packages\pip-9.0.1.dist-info\description.rst’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File «C:Program FilesPython36libsite-packagespipbasecommand.py», line 215, in main
status = self.run(options, args)
File «C:Program FilesPython36libsite-packagespipcommandsinstall.py», line 342, in run
prefix=options.prefix_path,
File «C:Program FilesPython36libsite-packagespipreqreq_set.py», line 778, in install
requirement.uninstall(auto_confirm=True)
File «C:Program FilesPython36libsite-packagespipreqreq_install.py», line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File «C:Program FilesPython36libsite-packagespipreqreq_uninstall.py», line 115, in remove
renames(path, new_path)
File «C:Program FilesPython36libsite-packagespiputils__init__.py», line 267, in renames
shutil.move(old, new)
File «C:Program FilesPython36libshutil.py», line 559, in move
os.unlink(src)
PermissionError: [WinError 5] Отказано в доступе: ‘c:\program files\python36\lib\site-packages\pip-9.0.1.dist-info\description.rst’
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the ‘python -m pip install —upgrade pip’ command.

Что означает ошибка ModuleNotFoundError: No module named
Python ругается, что не может найти нужный модуль
Python ругается, что не может найти нужный модуль
Ситуация: мы решили заняться бигдатой и обработать большой массив данных на Python. Чтобы было проще, мы используем уже готовые решения и находим нужный нам код в интернете, например такой:
import numpy as np
x = [2, 3, 4, 5, 6]
nums = np.array([2, 3, 4, 5, 6])
type(nums)
zeros = np.zeros((5, 4))
lin = np.linspace(1, 10, 20)
Копируем, вставляем в редактор кода и запускаем, чтобы разобраться, как что работает. Но вместо обработки данных Python выдаёт ошибку:
❌ModuleNotFoundError: No module named numpy
Странно, но этот код точно правильный: мы его взяли из блога разработчика и, по комментариям, у всех всё работает. Откуда тогда ошибка?
Что это значит: Python пытается подключить библиотеку, которую мы указали, но не может её найти у себя.
Когда встречается: когда библиотеки нет или мы неправильно написали её название.
Что делать с ошибкой ModuleNotFoundError: No module named
Самый простой способ исправить эту ошибку — установить библиотеку, которую мы хотим подключить в проект. Для установки Python-библиотек используют штатную команду pip или pip3, которая работает так: pip install <имя_библиотеки>. В нашем случае Python говорит, что он не может подключить библиотеку Numpy, поэтому пишем в командной строке такое:
pip install numpy
Это нужно написать не в командной строке Python, а в командной строке операционной системы. Тогда компьютер скачает эту библиотеку, установит, привяжет к Python и будет ругаться на строчку в коде import numpy.
Ещё бывает такое, что библиотека называется иначе, чем указано в команде pip install. Например, для работы с телеграм-ботами нужна библиотека telebot, а для её установки надо написать pip install pytelegrambotapi. Если попробовать подключить библиотеку с этим же названием, то тоже получим ошибку:

А иногда такая ошибка — это просто невнимательность: пропущенная буква в названии библиотеки или опечатка. Исправляем и работаем дальше.
Вёрстка:
Кирилл Климентьев
При установке библиотек происходит ошибка:
C:Windowssystem32>pip install wget
Collecting wget
Downloading wget-3.2.zip
Installing collected packages: wget
Running setup.py install for wget … error
Exception:
Traceback (most recent call last):
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipcompat__init__.py”, line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe4 in position 38: invalid
continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipbasecommand.py”, line 215, in main
status = self.run(options, args)
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipcommandsinstall.py”, line 342, in run
prefix=options.prefix_path,
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipreqreq_set.py”, line 784, in install
**kwargs
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipreqreq_install.py”, line 878, in install
spinner=spinner,
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
piputils__init__.py”, line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File “c:usersденappdatalocalprogramspythonpython36-32libsite-packages
pipcompat__init__.py”, line 75, in console_to_str
return s.decode(‘utf_8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe4 in position 38: invalid
continuation byte
Запускаю из под администратора, если использовать команду pip3 ошибка тоже происходит.
Ошибка происходит на всех версиях python >3.4
Также ошибка происходит при установке библиотек с tar.gz, а whl устанавливается без проблем.
This is not exactly a bug, it’s that there are no release wheels yet for 3.11, use pip install pygame --pre (--pre stands for pre release), it will install pygame 2.1.3.dev8 and you can use that, 2.1.3 is coming soon but I can’t tell for sure when.
AntonioGms2007, ghanteyyy, freebird-2, Heebeaux, Be3y4uu-K0T, mikiweys, hit-the-dust, RodionYalyna, theRealProHacker, NikBandi, and 3 more reacted with laugh emoji
marurunk, Px228, puisigblk, LeStefan04, bikrampun, and Assentencia reacted with heart emoji
Was able to duplicate this issue with:
- Python 3.11.0
- macOS Monterey 12.6
- Pygame 2.1.2
I usedpip3 install pygameand got a huge error message, as shown in the OP.
I do have a question, if there is no wheel made for Python3 3.11.0, is installing pygame 2.1.3.dev8 the only option? Is this release stable?
@arknaut Well, that’s the latest version of pygame that has wheels for Python 3.11 so it would be the most stable for that version of Python. Also, yeah, it should be stable enough on its own anyways, but again, it’s kind of temporary, I can’t tell for sure (or at all) but soon wheels for 2.1.3 should be released and they will be made for 3.11 too.
@Matiiss — Okay thanks! (just clarifying) pygame 2.1.3.dev8 has been released as a temporary version of pygame so that python 3.11.0 users can continue using pygame.
Uh, no, it’s more like 2.1.3.dev8 (it’s technically a pre-release btw) happens to have wheels for Python 3.11, it’s not specifically temporarily released for 3.11 because really 2.1.3 is kind of released already, it just doesn’t have wheels yet. But don’t take my word for it, however, I’m pretty sure it’s not something specifically done.
2.1.3dev8 is the only version with 3.11 wheels prebuilt. If you really want to use 2.1.2, you’ll have to build the wheels yourself. But 2.1.3dev8 is essentially the full 2.1.3 release, but in pre-release form. It wasn’t specifically released to target 3.11, but since 3.11 was coming out soon, compatibility with 3.11 was added to dev8 by starbuck5 and ankith
Are there any updates on this? Or an ETA for the new Pygame version?
Hello everyone. I observe the same problem on Armbian
pip install pygame
Defaulting to user installation because normal site-packages is not writeable
Collecting pygame
Downloading pygame-2.1.2.tar.gz (10.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 3.5 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [30 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config.py", line 225, in main
deps = CFG.main(**kwds)
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config_unix.py", line 188, in main
DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
File "/tmp/pip-install-m1yp62ur/pygame_44d4c02831ed4c49940d26d640b55b6a/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
IndexError: list index out of range
Hunting dependencies...
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
@rammfire if you read a few messages above, Matiiss gave the solution
@rammfire if you read a few messages above, Matiiss gave the solution
Unfortunately this is not really a solution for other packages that depend on Pygame.
For instance, I am about to release a new version of Expyriment, which depends on Pygame, and I am currently mainly holding it back due to this issue. Would be great to have some idea on when proper Python 3.11 support is planned (roughly, like within the next few days, or will it still be months?).
@fladd The full release of 2.1.3 is almost out. I’m hoping it’ll be within a week or two at most, but that’s really up to the discretion of the lead maintainer right now
Cant wait for the full release ! 😄
PeterJCLaw
added a commit
to PeterJCLaw/python-osc
that referenced
this issue
Nov 17, 2022
This was referenced
Nov 17, 2022
Though pip install pygame --pre works on python 3.11 on my windows 11. I would like to use the release version of pygame. 😄
Looking forward to pygame-2.1.3.
C:UsersLiu.D.H>pip install pygame --pre
Collecting pygame
Downloading pygame-2.1.3.dev8-cp311-cp311-win_amd64.whl (10.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.6/10.6 MB 4.8 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.1.3.dev8
C:UsersLiu.D.H>
C:UsersLiu.D.H>pip install pygame —pre
Can confirm this works. (Tested on Win10)
I would advocate for a point release that basically doesn’t change anything from the previous, but simply provides wheels for the new python version. A lot of beginners will get caught up on this while a new patch release is prepared. e.g., 2.1.3 simply ships additional 3.11 wheels, 2.1.4 gets moved to new patch release.
I would advocate for a point release that basically doesn’t change anything from the previous, but simply provides wheels for the new python version. A lot of beginners will get caught up on this while a new patch release is prepared. e.g., 2.1.3 simply ships additional 3.11 wheels, 2.1.4 gets moved to new patch release.
To the best of my knowledge, 2.1.3 is ready for release. Just waiting on the head maintainer to actually release it.
@fladd The full release of 2.1.3 is almost out. I’m hoping it’ll be within a week or two at most, but that’s really up to the discretion of the lead maintainer right now
Since it has been over a month now: Is there any news regarding the release?
Since it has been over a month now: Is there any news regarding the release?
To the best of my knowledge, the lead maintainer has not said anything to anyone in that time. Nobody else has the ability to release 2.1.3, so unfortunately we’re stuck waiting
@illume Python 3.11 has been out for a month and a half (and pygame’s main branch has been on 2.1.4dev1 for just as long). More and more people are starting to move to 3.11 and the fact that the only version of pygame with support for 3.11 requires knowledge of how to install a prerelease might detract users from continuing to use pygame. Is there something specific holding back the release? There are also other projects that are waiting for pygame 2.1.3 to fully release so they can update their dependencies.
I’ve tried and tried, but can’t even instal the pre-release.
RPi 4B, Bullseye (64-bit), Python3.11.
pi@rxtouchlite:~/pgtest $ pip install pygame —pre
Collecting pygame
Downloading pygame-2.1.3.dev8.tar.gz (12.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.1/12.1 MB 2.8 MB/s eta 0:00:00
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/setup.py", line 399, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config.py", line 231, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py", line 189, in main
DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
~~~~~~^^^
IndexError: list index out of range
Hunting dependencies...
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Are you sure you are using the pip from python 3.11 there? Pis come with
multiple python versions. I thought you had to use pip3 on there
…
On Sat, 17 Dec 2022, 11:38 Michael Naylor, ***@***.***> wrote:
I’ve tried and tried, but can’t even instal the pre-release.
RPi 4B, Bullseye (64-bit), Python3.11.
***@***.***:~/pgtest $ pip install pygame —pre
Collecting pygame
Downloading pygame-2.1.3.dev8.tar.gz (12.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.1/12.1 MB 2.8 MB/s eta 0:00:00
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
WARNING, No «Setup» File Exists, Running «buildconfig/config.py»
Using UNIX configuration…
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File «<string>», line 2, in <module>
File «<pip-setuptools-caller>», line 34, in <module>
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/setup.py», line 399, in <module>
buildconfig.config.main(AUTO_CONFIG)
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config.py», line 231, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py», line 189, in main
DependencyProg(‘SDL’, ‘SDL_CONFIG’, ‘sdl2-config’, ‘2.0’, [‘sdl’]),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File «/tmp/pip-install-9_sp3ju8/pygame_06121d1e121e4eafb99504b0ad01a83b/buildconfig/config_unix.py», line 39, in __init__
self.ver = config[0].strip()
~~~~~~^^^
IndexError: list index out of range
Hunting dependencies…
—
For help with compilation see:
https://www.pygame.org/wiki/Compilation
To contribute to pygame development see:
https://www.pygame.org/contribute.html
—
[end of output]
note: This error originates from a subprocess, and is likely not a problem
with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
—
Reply to this email directly, view it on GitHub
<#3522 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGDGGRVNWTT24EY5AYKHATWNWQ4BANCNFSM6AAAAAARQJB5DY>
.
You are receiving this because you commented.Message ID:
***@***.***>
Are you sure you are using the pip from python 3.11 there? Pis come with multiple python versions. I thought you had to use pip3 on there
…
I think so. Both ‘pip’ and ‘pip3’ report version 22.3.1 from the same ‘penv global 3.11.0’.
Ah, I suspect it is because the pi is looking on the piwheels repository instead of PyPI and it won’t find any 3.11 wheels on piwheels because piwheels only builds wheels for a maximum of python 3.9.
If your pip is configured to use piwheels, but you want to use PyPI instead, you can remove or comment out the extra-index-url configuration in /etc/pip.conf
Otherwise you will have to learn to build pygame from source if you want to use 3.11 on a raspberry PI.
Trinkle23897
added a commit
to Trinkle23897/envpool
that referenced
this issue
Dec 28, 2022
This was referenced
Dec 30, 2022
Had same error. Used temporary fix.
Please, please, please post this solution on the homepage of Pygame!
I’m an experienced coder but new to python and spent several hours thinking I had done something wrong.
Unfortunately, the only person with access to the pygame.org website is the same person that can fix this whole mess in the first place. But, they’ve been unresponsive so far.
But, they’ve been unresponsive so far.
Bummer. First installs always seem to go sideways. 🙁
Pip Installs Packages (“pip”) – это система организации пакетов для установки и работы с программными пакетами Python. Обычно он используется для пакетов Python Package Index.
При установке пакетов Python многие пользователи сообщают о получении сообщение “’pip’“ не распознается как внутренняя или внешняя команда” и не знаете, как устранить неполадки. Если вы видите эту ошибку, прочитайте советы о том, как ее исправить.
Давайте рассмотрим две наиболее распространенные причины этой ошибки:
Установка Pip отсутствует в системе Переменная
Чтобы команды Python запускались из командной строки Windows, путь установки pip необходимо добавить в системную переменную PATH. Он должен быть добавлен автоматически, если вы установили Python через установочный файл.
Установка была добавлена в ваш PATH неправильно
Если вы вручную добавили путь, проблема может быть просто опечатка. Одна пропущенная точка с запятой перед новым путем или лишний пробел где-нибудь вызовут ошибку.
Как исправить ‘Pip‘ не распознается как внутренняя или внешняя команда в Windows 10
Попробуйте следующие исправления, чтобы решить проблему в Windows 10:
Исправление 1. Убедитесь, что Pip был добавлен в вашу переменную PATH
Если вы уверены, что он был добавлен, продолжайте чтобы исправить 3.
Вот быстрый способ проверить:
- Откройте “Выполнить“ диалоговое окно, нажав клавишу Windows + R.

- Введите “cmd“ и нажмите Введите.

- для получения списка всех местоположений. добавленный в переменную PATH, введите “echo %PATH%“ в командную строку, затем нажмите Ввод.

- Если вы найдете путь вида “C:Python39Scripts” (в зависимости от вашей версии Python) путь был добавлен в переменную PATH.
Если пункт не был добавлен, попробуйте следующее исправление.
Исправление 2. Добавьте пункт в переменную среды PATH
Вот как вручную добавьте pip в среду PATH с помощью графического интерфейса Windows и командной строки. После добавления пути откройте новое командное окно и попробуйте установить пакет pip, чтобы увидеть, решена ли проблема.
Добавить pip в PATH с помощью графического интерфейса Windows:
- Откройте “Выполнить“ диалоговое окно, нажав клавишу Клавиша Windows + R.

- Введите “ sysdm.cpl“ и нажмите Ввод, чтобы открыть Свойства системы.

- Выберите вкладку Дополнительно, затем Переменные среды.

- Перейдите к Системные переменные и выберите Путь.

- Нажмите кнопку Изменить.
- Нажмите Создать.чтобы добавить путь установки pip. Расположение по умолчанию: “C:users“ваше имя пользователя“AppDataProgramsPythonPython39“ для Python 3.9.

Добавить пункт в PATH с помощью CMD:
- Откройте диалоговое окно Выполнить, нажав клавишу Windows + R.

- Чтобы открыть новое окно командной строки, введите “cmd“ и нажмите Ввод.

- Введите команду “setx PATH “%PATH%; C:Python39Scripts“ и нажмите Enter, чтобы запустить его.

Примечание. Если вы установили Python в другом месте, измените путь после “;“ соответственно.
Исправление 3. Откройте пакет Python без добавления переменной Pip
Выполните следующие действия, чтобы открыть установочные пакеты Python в CMD без добавления переменной pip:
- Нажмите клавишу Windows + R, чтобы откройте Выполнить.

- Введите “ cmd“ и нажмите Ввод, чтобы открыть командную строку.

- Введите команду “python -m pip install (имя пакета)“ и запустите его.

Исправление 4. Убедитесь, что Pip включен в установку
Некоторые установщики Python исключают pip из установки по умолчанию. Это можно исправить, изменив установку Python, включив в нее pip. Вот как это сделать:
- Нажмите клавишу Windows + R, чтобы открыть Выполнить.

- Введите “appwiz.cpl“ и Введите.

- В Программы и компоненты, щелкните правой кнопкой мыши Python и выберите Изменить.

- Выберите Изменить.

- В разделе Дополнительные функции установите флажок pip и нажмите Далее.

- Чтобы применить изменения, нажмите Установить.

- По завершении установки откройте окно CMD, чтобы проверить, можете ли вы установить пакет Python без появления ошибки.
Если вы все еще видите ошибку, перейдите к последнему разделу в этой статье приведены инструкции по удалению и переустановке Python 3.9.
Как исправить ‘Pip‘ не распознается как внутренняя или внешняя команда в коде Visual Studio
Если вы видите это сообщение об ошибке при работе с Visual Code, это обычно означает, что возникла проблема с установкой Python или PATH был задан неправильно. Воспользуйтесь следующими советами, чтобы решить эту проблему:
Решение 1. Убедитесь, что ‘Pip’ добавлен в вашу переменную PATH
Если вы уверены, что пункт был добавлен, перейдите к исправлению 3.
Чтобы проверить, что пункт был добавлен в вашу переменную PATH:
- Нажмите клавишу Windows + R, чтобы открыть Выполнить.

- Введите “cmd“ а затем нажмите Ввод для командной строки.

- Список местоположений, добавленных в вашей переменной PATH, введите “echo %PATH%“ и нажмите Ввод.

- Увидев путь типа “C:Python39Scripts“ означает, что путь был добавлен в переменную PATH.
Если пункт не был добавлен, попробуйте добавить его одним из следующих двух способов:
Исправить 2. Добавьте пункт в переменную среды PATH
Выполните следующие действия, чтобы добавить вручную pip в среду пути с помощью графического интерфейса Windows или CMD. После добавления пути откройте новое окно CMD и попробуйте установить пакет pip, чтобы увидеть, решена ли проблема.
Добавьте pip в PATH с помощью графического интерфейса Windows:
- Откройте “Выполнить” диалоговое окно, нажав клавишу Windows + R.

- Введите “sysdm.cpl” и нажмите “Ввод” для доступа к “Свойствам системы”

- Выберите “ Расширенный” вкладку, затем “Переменные среды”

- Перейдите в “Системные переменные” и выберите “Путь”

- Нажмите “Изменить&rdquo ;

- Нажмите “Создать” чтобы добавить путь установки pip. Расположение по умолчанию: “C:users”ваше имя пользователя”AppDataProgramsPythonPython39” для Python 3.9.

Добавить пункт в PATH с помощью CMD:
- Откройте диалоговое окно Выполнить, нажав клавишу Windows + R.

- Чтобы открыть новое окно командной строки, введите “cmd” и нажмите Ввод.

- Введите команду “setx PATH “%PATH%; C:Python39Scripts” и нажмите Enter, чтобы запустить его.

Исправление 3. Открытие пакета Python без добавления переменной pip
Выполните следующие действия, чтобы открыть установочные пакеты Python в CMD без добавления переменной pip:
- Откройте диалоговое окно Выполнить.

- Введите “cmd” и нажмите Ввод, чтобы открыть командную строку.

- Введите команду “python -m pip install (имя пакета)” и запустите его.

Исправление 4. Убедитесь, что Pip включен в установку
Некоторые установщики Python опускают pip из установки по умолчанию. Это можно исправить, изменив установку Python, включив в нее pip. Вот как это сделать:
- Нажмите клавишу Windows + R, чтобы открыть Выполнить.

- Введите “appwiz.cpl” и Введите.

- В Программа и функции, щелкните правой кнопкой мыши Python и выберите Изменить.

- Выберите Изменить.

- Чтобы применить изменения, нажмите Установить.

- По завершении установки откройте окно CMD, чтобы проверить, можете ли вы установить пакет Python без появления ошибки.
< li id=»step5″>В разделе Дополнительные функции установите флажок pip и нажмите Далее.
Если вы все еще видите ошибку, перейдите к последнему раздел этой статьи, чтобы узнать, как удалить и переустановить Python 3.9.
Переустановите Python, чтобы исправить ‘Pip’ не распознается как внутренняя или внешняя команда
Эта ошибка обычно означает наличие проблемы с установкой Python или неправильную настройку системной переменной PATH. Попробуйте переустановить Python и все его компоненты, чтобы устранить проблему. Самый простой способ — через исполняемый установщик Python. Вот как это сделать:
- откройте диалоговое окно Выполнить.

- Запустите “appwiz.cpl“ чтобы перейти к разделу Программы и компоненты.

- Прокрутите список программ вниз, чтобы найти установку Python.

- Щелкните его правой кнопкой мыши и выберите Удалить, затем следуйте инструкциям.

- После удаления Python перезагрузите компьютер и загрузите последнюю версию установщика Python для вашего ОС.

- Запустите установочный файл и убедитесь, что Флажок Добавить Python 3.x в PATH установлен, где x означает любую версию Python 3, которая у вас есть. >
- Выберите Настроить установку.

- В разделе Дополнительные функции убедитесь, что установлен флажок pip, затем нажмите Далее.

- Расположение по умолчанию можно оставить как есть, нажмите Установить.

- После завершения установки вам будет предложено перезагрузить компьютер.< /li>
- После перезагрузки компьютера попробуйте снова установить пакет Python.
Pip теперь распознается
“&lsquo ;пип’ не распознается как внутренняя или внешняя команда“ сообщение об ошибке распространено. Причина обычно заключается в том, что путь установки pip недоступен или неправильно добавлен в путь системной переменной. Есть несколько способов решить эту проблему. Вы можете добавить его вручную через графический интерфейс Windows или CMD, изменить установку Python, включив в нее pip, или удалить и переустановить Python, чтобы убедиться, что “pip“ параметры проверены.
Удалось ли вам распознать pip? Что вы сделали, чтобы решить проблему? Расскажите нам в разделе комментариев ниже.