python2.7 -m pip install socket
Collecting socket
Using cached socket-0.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-NGBb1T/socket/setup.py", line 2, in <module> raise RuntimeError("Package 'socket' must not be downloaded from pypi")
RuntimeError: Package 'socket' must not be downloaded from pypi
Command «python setup.py egg_info» failed with error code 1 in /tmp/pip-build-NGBb1T/socket/
Gianluca
3,2072 gold badges34 silver badges35 bronze badges
asked Feb 21, 2017 at 13:37
3
If you just want to use the python socket then you don’t need to install it seperately, coz it’s already included in standard library.
But if you are trying to install some other package which requires socket lib , then in setup.py
of that package, you can see it consists of a single line:
raise RuntimeError("Package 'socket' must not be downloaded from pypi")
socket
module is already included in the standard library. You don’t have to download anything. Just type import socket
and you’re all set.
answered Feb 21, 2017 at 14:50
U.SwapU.Swap
1,8914 gold badges23 silver badges41 bronze badges
I am unable to get pip install python-twitter
to successfully install this package from within my virtual machine, although I can install other pip packages successfully.
To reproduce:
- Install Vagrant and Virtualbox
vagrant up
with ubuntu/trusty64vagrant ssh
pip install urllib3[secure]
(without this, the same error occurs, but with an extraInsecurePlatformWarning
)pip install python-twitter
The error itself:
$ pip install python-twitter
Downloading/unpacking python-twitter
Downloading python-twitter-3.1.tar.gz (80kB): 80kB downloaded
Running setup.py (path:/tmp/pip_build_vagrant/python-twitter/setup.py) egg_info for package python-twitter
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_vagrant/python-twitter/setup.py", line 75, in <module>
'Programming Language :: Python :: 3.5',
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 239, in __init__
self.fetch_build_eggs(attrs.pop('setup_requires'))
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 264, in fetch_build_eggs
replace_conflicting=True
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 620, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 858, in best_match
return self.obtain(req, installer) # try and download/install
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 870, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 314, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 604, in easy_install
self.local_index
File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 602, in fetch_distribution
return dist.clone(location=self.download(dist.location, tmpdir))
File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 518, in download
found = self._download_url(scheme.group(1), spec, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 766, in _download_url
return self._attempt_download(url, filename)
File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 772, in _attempt_download
headers = self._download_to(url, filename)
File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 682, in _download_to
block = fp.read(bs)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
File "/usr/lib/python2.7/httplib.py", line 573, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read
return self._sslobj.read(len)
socket.error: [Errno 104] Connection reset by peer
When I run the command pip install scipy in my virtual python environment to install the python scipy library, I meet the socket.timeout: The read operation timed out error. This article will tell you how to fix it.
1. How To Fix The Error Socket.timeout: The Read Operation Timed Out When Run Pip Install Command.
- Below is the detailed error message.
(MyPythonEnv) C:Userszhaosong>pip install scipy Collecting scipy Downloading scipy-1.7.1-cp38-cp38-win_amd64.whl (33.7 MB) |████ | 4.4 MB 13 kB/s eta 0:37:21ERROR: Exception: Traceback (most recent call last): File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorurllib3response.py", line 438, in _error_catcher yield File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorurllib3response.py", line 519, in read data = self._fp.read(amt) if not fp_closed else b"" File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorcachecontrolfilewrapper.py", line 62, in read data = self.__fp.read(amt) File "C:Userszhaosonganaconda3envsMyPythonEnvlibhttpclient.py", line 458, in read n = self.readinto(b) File "C:Userszhaosonganaconda3envsMyPythonEnvlibhttpclient.py", line 502, in readinto n = self.fp.readinto(b) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsocket.py", line 669, in readinto return self._sock.recv_into(b) File "C:Userszhaosonganaconda3envsMyPythonEnvlibssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "C:Userszhaosonganaconda3envsMyPythonEnvlibssl.py", line 1099, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalclibase_command.py", line 173, in _main status = self.run(options, args) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalclireq_command.py", line 203, in wrapper return func(self, options, args) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalcommandsinstall.py", line 315, in run requirement_set = resolver.resolve( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibresolver.py", line 94, in resolve result = self._result = resolver.resolve( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorresolvelibresolvers.py", line 472, in resolve state = resolution.resolve(requirements, max_rounds=max_rounds) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorresolvelibresolvers.py", line 341, in resolve self._add_to_criteria(self.state.criteria, r, parent=None) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorresolvelibresolvers.py", line 172, in _add_to_criteria if not criterion.candidates: File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorresolvelibstructs.py", line 151, in __bool__ return bool(self._sequence) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibfound_candidates.py", line 140, in __bool__ return any(self) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibfound_candidates.py", line 128, in <genexpr> return (c for c in iterator if id(c) not in self._incompatible_ids) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibfound_candidates.py", line 32, in _iter_built candidate = func() File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibfactory.py", line 204, in _make_candidate_from_link self._link_candidate_cache[link] = LinkCandidate( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibcandidates.py", line 295, in __init__ super().__init__( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibcandidates.py", line 156, in __init__ self.dist = self._prepare() File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibcandidates.py", line 227, in _prepare dist = self._prepare_distribution() File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalresolutionresolvelibcandidates.py", line 305, in _prepare_distribution return self._factory.preparer.prepare_linked_requirement( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internaloperationsprepare.py", line 508, in prepare_linked_requirement return self._prepare_linked_requirement(req, parallel_builds) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internaloperationsprepare.py", line 550, in _prepare_linked_requirement local_file = unpack_url( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internaloperationsprepare.py", line 239, in unpack_url file = get_http_url( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internaloperationsprepare.py", line 102, in get_http_url from_path, content_type = download(link, temp_dir.path) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalnetworkdownload.py", line 145, in __call__ for chunk in chunks: File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalcliprogress_bars.py", line 144, in iter for x in it: File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_internalnetworkutils.py", line 63, in response_chunks for chunk in response.raw.stream( File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorurllib3response.py", line 576, in stream data = self.read(amt=amt, decode_content=decode_content) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorurllib3response.py", line 541, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "C:Userszhaosonganaconda3envsMyPythonEnvlibcontextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) File "C:Userszhaosonganaconda3envsMyPythonEnvlibsite-packagespip_vendorurllib3response.py", line 443, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
- Finally, I find the method to fix it, just need to specify a PyPI repository mirror near to me, and then use the mirror with the -i or –index-url parameter of the pip install command like below.
- The -i or –index-url parameter’s value points out the Python Package Index base URL, the default value is https://pypi.python.org/simple if you do not provide it.
pip install scipy -i https://mirrors.sustech.edu.cn/pypi/simple
- Now the pip installation speed is very fast and successful.
(MyPythonEnv) C:Userszhaosong>pip install scipy -i https://mirrors.sustech.edu.cn/pypi/simple Looking in indexes: https://mirrors.sustech.edu.cn/pypi/simple Collecting scipy Downloading https://mirrors.sustech.edu.cn/pypi/packages/90/39/b9452a3879b0baea4041d6b344bfad37aacfaadaafe945b47bb475ab8c7a/scipy-1.7.1-cp38-cp38-win_amd64.whl (33.7 MB) |████████████████████████████████| 33.7 MB 3.3 MB/s Requirement already satisfied: numpy<1.23.0,>=1.16.5 in c:userszhaosonganaconda3envsmypythonenvlibsite-packages (from scipy) (1.20.3) Installing collected packages: scipy Successfully installed scipy-1.7.1
- I found some PyPI repository mirror URLs from the internet, and you can google others or create your own. Note: the new version of Ubuntu requires HTTPS source。
https://pypi.tuna.tsinghua.edu.cn/simple http://mirrors.aliyun.com/pypi/simple/ https://pypi.mirrors.ustc.edu.cn/simple/ http://pypi.hustunique.com/ http://pypi.sdutlinux.org/ http://pypi.douban.com/simple/
I tried installing django but didn’t work. Instead it gave me this error…
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(‘: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions’)’: /simple/django/
ERROR: Could not find a version that satisfies the requirement django (from versions: none)
ERROR: No matching distribution found for django
I tried to install other packages and modules but none of them could be installed. I reinstalled python and while doing that I lose all my previous packages. I had a project with PyQt5 which I could install successfully two weeks ago but after I reinstalled python my packages, modules, etc. where gone and now pip won’t work I don’t know why.
I tried changing my network and tried using my phone’s hotspot but it didnt solve the problem. I tried giving the version name of the packages but that didn’t work either.
My network doesn’t have a proxy or is not connected to a vpn. I can download any other stuff but I just cannot download stuff with pip.
Thanks in advance!
@Nolrox
Python-разработчик
Качаю Python, захожу в консоль, пишу pip install и выдает что «pip» не является внутренней или внешней командой, исполняемой программой или пакетным файлом. Что делать?
-
Вопрос заданболее двух лет назад
-
51600 просмотров
Добавить в PATH.
Гугли переменные среды
Или даже будет быстрее переустановить питон и при установке поставить соответствующую галочку.
Если винда, то тут 99% что при установке не поставил галочку добавить пути в PATH.
1. Руками прописать
2. Удалить и поставить заново, не пропустив галочку
Скорее всего, у вас просто не была установлена галочка на работу пипа со всех директорий, или переустановите пайтон, почтавив эту галочку, илм пробуйте выполнять эту команду с директории где находится пайтон
Пригласить эксперта
Нужно обновить pip:
python -m pip install --upgrade pip
Скорее всего вы используете Python 3.9. Но многие мейнтейнеры не успели обновить пакеты. Поэтому установите Python 3.8
Discord.py поддерживается пока питоном 3.5 … 3.8!
И неплохо бы установить Microsoft C++ Build Tools, пригодится для установки некоторых пакетов.
если галочка PATH python не сработала можно: настроить ручную.
здесь объясняют как в ручную настроить PATH для python (для pip достаточно просто указать в PATH адрес к scripts в каталоге python)
-
Показать ещё
Загружается…
04 июн. 2023, в 12:07
2000 руб./за проект
04 июн. 2023, в 12:06
1000 руб./за проект
04 июн. 2023, в 12:06
30000 руб./за проект