# Error when installing matplotib in Slicer

**URL:** <https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141>\
**Category:** Development\
**Tags:** python, pip\
**Created:** [March 2, 2023, 12:25pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141 "2023-03-02T12:25:03Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [March 2, 2023, 12:25pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/1 "2023-03-02T12:25:03Z")

</div>

I’m trying to install matplotlib package in python-interactor in Slicer 5.0.2 with the following commands:

```auto
from slicer.util import pip_install
pip_install("matplotlib")
import matplotlib.pyplot as plt

```

I get the following error:

```auto
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/matplotlib/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/matplotlib/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/matplotlib/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/matplotlib/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/matplotlib/
Could not fetch URL https://pypi.org/simple/matplotlib/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/matplotlib/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
ERROR: Could not find a version that satisfies the requirement matplotlib (from versions: none)
ERROR: No matching distribution found for matplotlib
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
Traceback (most recent call last):
  File "D:/DESKTOP/ex/module3/module3.py", line 480, in readPic
    pip_install("matplotlib")
  File "E:\Slicer 5.0.2\bin\Python\slicer\util.py", line 3431, in pip_install
    _executePythonModule('pip', args)
  File "E:\Slicer 5.0.2\bin\Python\slicer\util.py", line 3394, in _executePythonModule
    logProcessOutput(proc)
  File "E:\Slicer 5.0.2\bin\Python\slicer\util.py", line 3363, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['E:/Slicer 5.0.2/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'matplotlib']' returned non-zero exit status 1.
...

```

as shown in the picture:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/9/493dc4a91f365eeaf6e24861fbacd398c4863df8.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 2, 2023, 12:31pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/2 "2023-03-02T12:31:48Z")

</div>

There seems to be an SSL error. There could be many reasons. Using the current Slicer version (5.2.2) may fix the problem. Let us know if the problem occurs in current Slicer version, too.

---

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [March 2, 2023, 2:26pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/3 "2023-03-02T14:26:08Z")

</div>

Yes, it still occurs…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/3/a37b2c9209568a721677f52b94351e1d1bfaa8ff.png)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 2, 2023, 4:27pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/4 "2023-03-02T16:27:28Z")

</div>

I encountered something very similar when I started a clean build of a Slicer custom app. This was the original error:

```auto
  Performing install step for 'python-pip'
  CMake Error at E:/t/tR/slicersources-build/python-pip-prefix/src/python-pip-stamp/python-pip-install-Release.cmake:49 (message):
    Command failed: 1
     'E:/t/tR/python-install/bin/PythonSlicer.exe' '-m' 'pip' 'install' '--require-hashes' '-r' 'E:/t/tR/python-pip-requirements.txt'
    See also
      E:/t/tR/slicersources-build/python-pip-prefix/src/python-pip-stamp/python-pip-install-*.log 

```

In the log file there was something like this:

```auto
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))': /packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))': /packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))': /packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))': /packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))': /packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-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/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))

WARNING: You are using pip version 22.0.3; however, version 23.0.1 is available.
You should consider upgrading via the 'E:\dt\dR\python-install\bin\python.exe -m pip install --upgrade pip' command.

```

First it happened with `python-setuptools` then `python-pip`, without changing anything. In the latter case it complained about pip version so I copied over the pip to site-packages from another, formerly successful build and then the build continued, but the same type of error happened with `python-numpy`, so I figured the problem is more central. Then I tried building another custom app, and the problem was the same, although that custom app was built successfully before. I think something may have changed in the infrastructure in the past 5-10 days.

Next I’m building a Slicer on the same machine, and will start both a custom app and a Slicer build on another machine on another network to try to pinpoint the issue, but I thought it’d be useful to share this info now in case it helps.

---

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [March 2, 2023, 4:40pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/5 "2023-03-02T16:40:26Z")

</div>

Thanks for sharing 😁. Let’s wait for a solution.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 3, 2023, 6:13am UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/6 "2023-03-03T06:13:09Z")

</div>

Try to disable third-party antivirus software if you have any (see [here](https://stackoverflow.com/questions/61990284/pip-install-fails-with-connection-error-ssl-problem)). It might also worth trying [this](https://marin-kitagawa.devlifematter.org/answer/error-when-use-pipwarning-retrying-retry-total=4-connect=none-read=none-redirect=none-status=none-after-connection-broken-by-readtimeouterror-httpscon-9508).

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 3, 2023, 11:01am UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/7 "2023-03-03T11:01:56Z")

</div>

I built regular Slicer (latest commit) and it failed the same way. At the same time on a different computer/network the build succeeded. It is a home computer so there should be no network limitations but evidently there is something. Thanks for the suggestions @lassoan I’ll look into those.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 3, 2023, 12:00pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/8 "2023-03-03T12:00:27Z")

</div>

I didn’t have any 3rd party antivirus, but trying the second link worked (in the sense that pip installing matplotlib as mentioned first in this topic succeeded).

In summary, the file `c:\Windows\System32\Drivers\etc\hosts` had to be opened with a text editor started as administrator, then these two lines added to the end:

```auto
151.101.0.223 pypi.org
151.101.1.63 files.pythonhosted.org

```

I’m building Slicer and the custom apps to confirm that everything works.

I’m a bit puzzled, because I didn’t install any relevant-looking application lately, nor have I made changes in firewall or other network settings, didn’t change internet providers etc, so all in all there have been no changes. Still, using pip worked perfectly before, and suddenly this problem started occurring. It would be interesting to know what caused it. But it’s great that it seems to be working now (pending the builds), thanks a lot @lassoan!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 3, 2023, 2:40pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/9 "2023-03-03T14:40:58Z")

</div>

@hapkx I marked Andras’ suggestion solution because it helped me, but please confirm it works for you as well, since this topic is coming from your side.

---

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [March 3, 2023, 6:11pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/10 "2023-03-03T18:11:25Z")

</div>

The second one works! Thank you! 😊

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 4, 2023, 3:16am UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/11 "2023-03-04T03:16:18Z")

</div>

@cpinter I’m just curious, do you have optical fiber connection to your internet service provider? Does disabling “TCP and UDP Checksum Offload for IPv6” (or TCP/IPv6 protocol completely) fixes the issue as well?

_From [https://www.reddit.com/r/Fios/comments/xo55n4/verizon\_just\_activated\_ipv6\_turning\_off\_ipv6\_tcp/](https://www.reddit.com/r/Fios/comments/xo55n4/verizon_just_activated_ipv6_turning_off_ipv6_tcp/) :_

1. Open the “Network Connections” page of the Windows Control Panel.
2. Open the “Properties” dialog of the NIC.
3. Select “Configure…” to open the NIC’s configuration.
4. Navigate to the Advanced tab and disable “TCP and UDP Checksum Offload for IPv6”.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 6, 2023, 3:14pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/12 "2023-03-06T15:14:39Z")

</div>

> [@lassoan](#):
>
> do you have optical fiber connection to your internet service provider?

Yes.

> [@lassoan](#):
>
> Does disabling “TCP and UDP Checksum Offload for IPv6” (or TCP/IPv6 protocol completely) fixes the issue as well?

Well, maybe I need some help. My Windows is set to English, but it was originally Spanish, and some parts are apparently not converted to English. Here’s the page in question:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/e/aedd241198e3179effa16729044a4db4e980bad7.png)

I guess the checksum offload is the one selected. But there are five of them, and Windows doesn’t let me resize this window and there are no tooltips either to see the end of these strings. I don’t want to just disable all of them because I don’t want to potentially break something.

Can you please check on your machine what are these four exactly? Maybe then we can guess the order of these and I can disable just the TCP and UDP ones.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 6, 2023, 3:17pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/13 "2023-03-06T15:17:53Z")

</div>

Well considering what could break I gave it a go anyway. I disabled all five, and it did not fix the issue.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 6, 2023, 4:02pm UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/14 "2023-03-06T16:02:36Z")

</div>

Here is my network interface properties list:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/d/bd7ff6040e18f9a38a65fc78ca1e7741cc2c24ae.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/7/a73ab87e3e79d177f461da525b00bb0be095edbc.png)

You can try temporarily disabling TCP/IPv6 to see if it makes a difference, just for testing.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 7, 2023, 10:24am UTC](https://discourse.slicer.org/t/error-when-installing-matplotib-in-slicer/28141/15 "2023-03-07T10:24:04Z")

</div>

OK I’ll try to disable IPv6 when appropriate. @hapkx if you’d like to help out you could try this one.
