Plotly in executable can't communicate with Orca server

Hello all,

This is a problem that I’ve been struggling with for almost a week now. I’ve found several posts with the same error message, but the cause seems to be different from mine in every case; none of the fixes seem to apply to me. I’m getting the following error:

C:\Users\I849168\Python\Email\Patch Email Generator>dist\EmailBuilderPrompt\EmailBuilderPrompt.exe
Traceback (most recent call last):
  File "site-packages\urllib3\connection.py", line 157, in _new_conn
  File "site-packages\urllib3\util\connection.py", line 84, in create_connection
  File "site-packages\urllib3\util\connection.py", line 74, in create_connection
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\urllib3\connectionpool.py", line 672, in urlopen
  File "site-packages\urllib3\connectionpool.py", line 387, in _make_request
  File "http\client.py", line 1244, in request
  File "http\client.py", line 1290, in _send_request
  File "http\client.py", line 1239, in endheaders
  File "http\client.py", line 1026, in _send_output
  File "http\client.py", line 966, in send
  File "site-packages\urllib3\connection.py", line 184, in connect
  File "site-packages\urllib3\connection.py", line 169, in _new_conn
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002546DE8FF88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\requests\adapters.py", line 449, in send
  File "site-packages\urllib3\connectionpool.py", line 720, in urlopen
  File "site-packages\urllib3\util\retry.py", line 436, in increment
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=51904): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002546DE8FF88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\plotly\io\_orca.py", line 1509, in to_image
  File "site-packages\retrying.py", line 49, in wrapped_f
  File "site-packages\retrying.py", line 212, in call
  File "site-packages\retrying.py", line 247, in get
  File "six.py", line 693, in reraise
  File "site-packages\retrying.py", line 200, in call
  File "site-packages\plotly\io\_orca.py", line 1418, in request_image_with_retrying
  File "site-packages\requests\api.py", line 116, in post
  File "site-packages\requests\api.py", line 60, in request
  File "site-packages\requests\sessions.py", line 533, in request
  File "site-packages\requests\sessions.py", line 646, in send
  File "site-packages\requests\adapters.py", line 516, in send
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=51904): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002546DE8FF88>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "EmailBuilderPrompt.py", line 1, in <module>
    import EmailBuilder as EmailBuilder
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\program files\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "EmailBuilder.py", line 175, in <module>
    main("b1911p4 (6-Dec-2019)", True)
  File "EmailBuilder.py", line 145, in main
    data.charts = pc.createCharts(data, dic.IMAGE_DIRECTORY, tkInitialized)
  File "PatchCharter.py", line 94, in createCharts
    chart.write_image(imgPath)
  File "PatchCharter.py", line 91, in createChart
    imgName = name.replace(" ", "") + ".png" # There's an error if you leave the spaces in.
  File "site-packages\plotly\basedatatypes.py", line 2688, in write_image
  File "site-packages\plotly\io\_orca.py", line 1705, in write_image
  File "site-packages\plotly\io\_orca.py", line 1529, in to_image
ValueError:
For some reason plotly.py was unable to communicate with the
local orca server process, even though the server process seems to be running.

Please review the process and connection information below:

orca status
-----------
    state: running
    executable: C:\Users\I849168\AppData\Local\Programs\orca\orca.EXE
    version: 1.2.1
    port: 51904
    pid: 28580
    command: ['C:\\Users\\I849168\\AppData\\Local\\Programs\\orca\\orca.EXE', 'serve', '-p', '51904', '--plotly', 'C:\\Users\\I849168\\Python\\Email\\Patch Email Generator\\dist\\EmailBuilderPrompt\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']



[29512] Failed to execute script EmailBuilderPrompt

Here’s the twist: I created an executable of my file using pyinstaller, and it’s only when I run the executable that I run into this problem. If I run the file as Python, I have no problem at all. But I need it to be an executable, because I can expect all the users to install all the various modules and dependencies required for the script. Can someone please help me? I’m using plotly version 4.1.1.

1 Like