# PythonCall just works when I close the REPL after importing OpenSSL\_jll, but I cannot make it work in the same session

**URL:** <https://discourse.julialang.org/t/pythoncall-just-works-when-i-close-the-repl-after-importing-openssl-jll-but-i-cannot-make-it-work-in-the-same-session/123122>\
**Category:** General Usage\
**Tags:** package, repl, pythoncall, ssl\
**Created:** [November 26, 2024, 7:55pm UTC](https://discourse.julialang.org/t/pythoncall-just-works-when-i-close-the-repl-after-importing-openssl-jll-but-i-cannot-make-it-work-in-the-same-session/123122 "2024-11-26T19:55:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![facusapienza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/facusapienza/32/24317_2.png) [@facusapienza](https://discourse.julialang.org/u/facusapienza)\
**Post date:** [November 26, 2024, 7:55pm UTC](https://discourse.julialang.org/t/pythoncall-just-works-when-i-close-the-repl-after-importing-openssl-jll-but-i-cannot-make-it-work-in-the-same-session/123122/1 "2024-11-26T19:55:08Z")

</div>

Hi all,

I am trying to make the following workflow involving PythonCall to work in the same Julia session. I am experiencing some problems with PythonCall and SSL credentials, which thanks to @cjdoris I managed to make work by the following workflow which involved **exit and enter again a new Julia session**.

1. In a new Julia session, I activate my envionment and then do  
`using OpenSSL_jll`
2. I **close the session** and open a new REPL
3. In a new session, I can simply now do  
`using PythonCall; pyimport("ssl")`

This workflow works, but if I just do the following in the same session

```julia
using OpenSSL_jll
using PythonCall; pyimport("ssl")

```

this returns instead the error

```julia
ERROR: Python: ImportError: dlopen(/Users/sapienza/.julia/dev/Sleipnir/.CondaPkg/env/lib/python3.12/lib-dynload/_ssl.cpython-312-darwin.so, 0x0002): Symbol not found: _X509_STORE_get1_objects
  Referenced from: <B1CE67CC-8161-3609-8F45-6B9EC2F14447> /Users/sapienza/.julia/dev/Sleipnir/.CondaPkg/env/lib/python3.12/lib-dynload/_ssl.cpython-312-darwin.so
  Expected in: <4C4C44CB-5555-3144-A104-41A9AFACD8FB> /Users/sapienza/.julia/artifacts/e33c9389fd079973c7a7520d36779612df7ec447/lib/libcrypto.3.dylib
Python stacktrace:
 [1] <module>
   @ ~/.julia/dev/Sleipnir/.CondaPkg/env/lib/python3.12/ssl.py:100
Stacktrace:
 [1] pythrow()
   @ PythonCall.Core ~/.julia/packages/PythonCall/Nr75f/src/Core/err.jl:92
 [2] errcheck
   @ ~/.julia/packages/PythonCall/Nr75f/src/Core/err.jl:10 [inlined]
 [3] pyimport(m::String)
   @ PythonCall.Core ~/.julia/packages/PythonCall/Nr75f/src/Core/builtins.jl:1561
 [4] top-level scope
   @ REPL[4]:1

```

Now, this is currently a big issue for me since I am trying to make this work inside a Julia package, so I need a workflow that works to be included in the main script of my library ([here](https://github.com/facusapienza21/Sleipnir.jl/blob/main/src/Sleipnir.jl)).

Furthermore, this is not a persistent solution, since the next time I want to do `pyimport("ssl")` I also need to open a Julia session before to do the `using OpenSSL_jll`. **Does anyone know what OpenSSL\_jll is exactly doing by just importing it right before the `pyimport`**?

I will highly appreciate if someone has some tip here that will help me progress on this problem!

Detains of the `CondaPkg.toml` used to generate the environment can be found [here](https://github.com/facusapienza21/Sleipnir.jl/blob/pythoncall2/CondaPkg.toml). The complete workflow can be easely reproduced from the [GitHub repo](https://github.com/facusapienza21/Sleipnir.jl).

(Sorry if this feel a bit repetitive from other post, but I imagined this is a more general Julia topic that can be helpful to others, so I imagined a standalone post will be better.)

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 26, 2024, 10:35pm UTC](https://discourse.julialang.org/t/pythoncall-just-works-when-i-close-the-repl-after-importing-openssl-jll-but-i-cannot-make-it-work-in-the-same-session/123122/2 "2024-11-26T22:35:18Z")

</div>

As of Python 3.13:

> **[3. Configure Python](https://docs.python.org/3/using/configure.html)**
>
> Build Requirements: Features and minimum versions required to build CPython: A C11 compiler. Optional C11 features are not required., On Windows, Microsoft Visual Studio 2017 or later is required.,...

> OpenSSL 1.1.1 is the minimum version and OpenSSL 3.0.9 is the recommended minimum version for the ssl and hashlib extension modules.

In Julia, and I think, per se, not contradictory (I see OpenSSL\_jll build 3.0.15+1, and e.g. older OpenSSL\_jll build 3.0.9+0 and OpenSSL\_jll build 1.1.1+6):

> OpenSSL\_jll = “1.1, 3.0”

OpenSSL 3 is the current long-term support (LTS) version, anything older is no longer supported, so I doubt you want to use 1.1.1 even if you can.

I think you want to use Python 3.13, and I seem to remember something about there possibly being a conflict between OpenSSL [versions] in Python and Julia. Do you actually need OpenSSL\_jll in Julia? Julia still uses MbedTLS, is that not good enough from the Julia side?

What is it exactly you need from the Python side, i.e. how do you load the package and confirm the version used?

```julia
Python 3.12.3 (main, Apr 21 2024, 17:40:47) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from OpenSSL import SSL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'OpenSSL'

```

I’ve been having trouble installing Python packages like this one, or knowing for sure which one[s] are recommended:

> **[pyOpenSSL](https://pypi.org/project/pyOpenSSL/)**
>
> Python wrapper module around the OpenSSL library

> **Note:** The Python Cryptographic Authority **strongly suggests** the use of [pyca/cryptography](https://github.com/pyca/cryptography) where possible. If you are using pyOpenSSL for anything other than making a TLS connection **you should move to cryptography and drop your pyOpenSSL dependency**.

Julia 1.12 will use OpenSSL 3, so best get used to it:

> <https://github.com/JuliaLang/julia/pull/53891>
>
> This is a test of migrating the source build to OpenSSL.

> <https://github.com/JuliaLang/julia/pull/56708>
>
> Based on @fxcoudert's openssl branch and pull request at https://github.com/Juli…aLang/julia/pull/53891.
> 
> \- diff re-applied to current Julia master (hence the new commit)
> \- LibCURL, LibGit2, LibSSH2, OpenSSL updated to newest version
> \- MbedTLS removed
