Skip to content

PDM cannot correctly import the ssl module after upgrade to Python 3.11.5 #2296

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

Closed
1 task done
igoforth opened this issue Oct 4, 2023 · 2 comments
Closed
1 task done
Labels
🤔 waiting for feedback Requires more information to clarify the issue

Comments

@igoforth
Copy link

igoforth commented Oct 4, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

  1. Upgrade to Python 3.11.5 and use it as PDM interpreter
  2. Run any PDM command that accesses the internet

Actual behavior

short:

/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/actions.py:318: RuntimeWarning: Failed to get latest version: Can't connect to HTTPS URL because the SSL module is not available.
  warnings.warn(f"Failed to get latest version: {e}", RuntimeWarning, stacklevel=1)

verbose:

~ pdm search -v ssl
Project is not found, fallback to the global project
Project is not found, fallback to the global project
Project is not found, fallback to the global project
Traceback (most recent call last):
  File "/home/kali/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 157, in handle
    command.handle(project, options)
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/commands/search.py", line 63, in handle
    result = project.get_repository().search(options.query)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/models/repositories.py", line 415, in search
    resp = session.get(search_url, params={"q": query})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/cachecontrol/adapter.py", line 76, in send
    resp = super().send(request, stream, timeout, verify, cert, proxies)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 769, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 295, in _get_conn    return conn or self._new_conn()
                   ^^^^^^^^^^^^^^^^
  File "/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1056, in _new_conn
    raise ImportError(
ImportError: Can't connect to HTTPS URL because the SSL module is not available.

repl:

~ /home/kali/.local/share/pdm/venv/bin/python
Python 3.11.4 (main, Jun  7 2023, 10:13:09) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/ssl.py", line 100, in <module>                                                                  
import _ssl             # if we can't import it, let the error propagate
    ^^^^^^^^^^^                                                                                                         
ImportError: /usr/lib/python3.11/lib-dynload/_ssl.cpython-311-x86_64-linux-gnu.so: undefined symbol: _PyModule_Add      
>>> quit()

Expected behavior

PDM correctly imports the ssl module.

See the issue here where Poetry has to be updated:
python/cpython#108525

Environment Information

# Paste the output of `pdm info && pdm info --env` below:~ pdm info && pdm info --env
Project is not found, fallback to the global project
Project is not found, fallback to the global project
Project is not found, fallback to the global project
PDM version:
  2.9.2
Python Interpreter:
  /usr/bin/python3 (3.11)
Project Root:
  /home/kali/.config/pdm/global-project
Local Packages:

/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/actions.py:318: RuntimeWarning: Failed to get latest version: Can't connect to HTTPS URL because the SSL module is not available.
  warnings.warn(f"Failed to get latest version: {e}", RuntimeWarning, stacklevel=1)
Project is not found, fallback to the global project
Project is not found, fallback to the global project
Project is not found, fallback to the global project
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.5",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.5.0-kali1-amd64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Debian 6.5.3-1kali1 (2023-09-19)",
  "python_full_version": "3.11.5",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}
/home/kali/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/actions.py:318: RuntimeWarning: Failed to get latest version: Can't connect to HTTPS URL because the SSL module is not available.
  warnings.warn(f"Failed to get latest version: {e}", RuntimeWarning, stacklevel=1)
@igoforth igoforth added the 🐛 bug Something isn't working label Oct 4, 2023
@frostming
Copy link
Collaborator

This has little to do with PDM. Confirm the following:

  1. Can you use ssl module in the host interpreter Python 3.11.5?
  2. Can you use ssl module in a virtualenv python created with Python 3.11.5? You can create one with virtualenv --python /usr/bin/python3, install the tool if not existing.

@frostming frostming added 🤔 waiting for feedback Requires more information to clarify the issue and removed 🐛 bug Something isn't working labels Oct 6, 2023
@igoforth
Copy link
Author

igoforth commented Oct 8, 2023

It was working fine on a different computer. So I'm going to look into it more and reopen if I discover any relevant problems.

@igoforth igoforth closed this as completed Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 waiting for feedback Requires more information to clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants