Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: check_hostname requires server_hostname #11473

Closed
1 task done
MisbahAwan opened this issue Sep 29, 2022 · 4 comments
Closed
1 task done

ValueError: check_hostname requires server_hostname #11473

MisbahAwan opened this issue Sep 29, 2022 · 4 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@MisbahAwan
Copy link

Description

I am unable to install using "pip install". I tried everything on internet but nothing worked for me.

pip install tensorflow==2.3.1 // this is I want to install

I am using jupyter notebook (python 3.10) with windows 8

Expected behavior

desired package installed.

pip version

pip 21.2.4

Python version

3.10

OS

windows

How to Reproduce

pip install tensorflow==2.3.1 ... run this

Output

ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\cli\base_command.py", line 173, in _main
status = self.run(options, args)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\cli\req_command.py", line 203, in wrapper
return func(self, options, args)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\commands\install.py", line 315, in run
requirement_set = resolver.resolve(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 94, in resolve
result = self._result = resolver.resolve(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 472, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 341, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\resolvelib\structs.py", line 151, in bool
return bool(self._sequence)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 140, in bool
return any(self)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 128, in
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 29, in _iter_built
for version, func in infos:
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\resolution\resolvelib\factory.py", line 272, in iter_index_candidate_infos
result = self._finder.find_best_candidate(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\package_finder.py", line 851, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\package_finder.py", line 798, in find_all_candidates
page_candidates = list(page_candidates_it)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\sources.py", line 134, in page_candidates
yield from self._candidates_from_page(self._link)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\package_finder.py", line 758, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\collector.py", line 490, in fetch_page
return _get_html_page(location, session=self.session)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\collector.py", line 400, in _get_html_page
resp = _get_html_response(url, session=session)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\index\collector.py", line 115, in _get_html_response
resp = session.get(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\requests\sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_internal\network\session.py", line 454, in request
return super().request(method, url, *args, **kwargs)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\cachecontrol\adapter.py", line 53, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\connection.py", line 500, in connect_tls_proxy
return ssl_wrap_socket(
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\util\ssl
.py", line 453, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\Users\misbah.awan\Anaconda3\lib\site-packages\pip_vendor\urllib3\util\ssl
.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "C:\Users\misbah.awan\Anaconda3\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\misbah.awan\Anaconda3\lib\ssl.py", line 997, in _create
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

Code of Conduct

@MisbahAwan MisbahAwan added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Sep 29, 2022
@notatallshaw
Copy link
Member

notatallshaw commented Oct 17, 2022

Likely you broke your Anaconda base environment by using pip install.

There is no guarantee that Pip will work well in Anaconda, especially the base environment. The supported way to install packages in Anaconda is using conda.

That said you will probably not have any luck installing Tensorflow in your base environment, it is a very complex package and installing it in to the base environment which is already very complex is unlikely to work.

I suggest that:

  1. You uninstall Anaconda, including deleting C:\Users\misbah.awan\Anaconda3
  2. Reinstall Anaconda
  3. Create a new environment using conda: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
  4. Install the packages you want in the new environment using conda, e.g. conda install ...
  5. Ask for troubleshooting help in the Anaconda community forum: https://community.anaconda.cloud/

@ichard26
Copy link
Member

ichard26 commented Apr 15, 2024

For those landing on this issue randomly, this is likely an issue with your Python environment or an incompatibility between Anaconda Python and pip. As noted above, you should use conda for installing packages in an Anaconda environment.

For maintainers: this issue can be closed as there's nothing pip can do without more context (other than raise a better error and/or provide better guidance which is already tracked in #5380.

@pfmoore pfmoore closed this as completed Apr 15, 2024
@notatallshaw
Copy link
Member

I will mention for those ending up here that conda and pip aren't mutually exclusive, but a few important points:

  1. If you are using Anaconda, the base environment shouldn't be touched, with either pip or conda ,except to upgrade the Anaconda meta package
  2. If you want a tool that supports both conda and regular Python packages check pixi out
  3. If you want conda environments with pip you're best using conda to install all the things that aren't Python packages (Python, nodejs, etc.) and then using pip to install all the things that are Python packages

@pfmoore
Copy link
Member

pfmoore commented Apr 15, 2024

I will mention for those ending up here that conda and pip aren't mutually exclusive

Absolutely, but as a broad generalisation, it's easier to not mix the two tools. In the case of this issue specifically, tensorflow is available from conda forge, so my immediate suggestion would be to use conda to install it, and not involve pip at all. And more generally, if you're thinking of using pip in a conda environment, start by asking yourself why you need to use pip, and whether it's worth the potential added complexity to do so. My understanding is that most packages are available on conda forge (possibly not the absolute latest versions, but is that crucial?) so it should be pretty rare for a conda user to actually need pip.

There's a broader education point here, but I don't think it's something pip can address alone - conda users need easier access to documentation that explains how to manage packages in a conda-native way, and not end up here because they could only find advice on how to do things with pip.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants