requests.exceptions.InvalidProxyURL: Please check proxy URL

Hi,

I created a python script to export a dimension structure. This script was then converted to an exe file using pyinstaller.

I then called this exe file via cmd in my machine. The exe worked and exported the data.
But when I used this exe in another machine, it gave out the highlighted error. Any idea how to sort this out?

code:
```
import configparser 
import os 
import sys cube_name = sys.argv[1] 
config = configparser.ConfigParser() 
cwd = os.getcwd() 
config.read(os.path.join(cwd, 'config.ini')) 
metadata_file = os.path.join(cwd, cube_name+'.xlsx') 
import pandas as pd 
from TM1py.Services import TM1Service 
from TM1py.Utils import Utils 
with TM1Service(**config['USCPADM_SIT']) as tm1: 
    all_cubes = tm1.cubes.get(cube_name) 
    dims = all_cubes.dimensions 
    with pd.ExcelWriter(metadata_file) as writer: 
        for dim in dims: 
            df = [] 
            dimension = tm1.dimensions.get(dim) for hierarchy in dimension: for element in hierarchy:                         
        df.append(element.name) pd.DataFrame(df).to_excel(writer, sheet_name=dim, header=False, 
index=False)
```


Error:

```
Traceback (most recent call last): File "dim.py", line 16, in 
File "site-packages\TM1py\Services\TM1Service.py", line 12, in **init** 
File "site-packages\TM1py\Services\RESTService.py", line 96, in **init** 
File "site-packages\TM1py\Services\RESTService.py", line 169, in _start_session 
File "site-packages\requests\sessions.py", line 525, in get 
File "site-packages\requests\sessions.py", line 512, in request 
File "site-packages\requests\sessions.py", line 622, in send 
File "site-packages\requests\adapters.py", line 388, in send 
File "site-packages\requests\adapters.py", line 292, in get_connection 
requests.exceptions.InvalidProxyURL: Please check proxy URL. It is malformed and could be missing the host. [10048] Failed to execute script dim
```


I tested the proxy settings in both the machines and the results were same:
`netsh winhttp show proxy`

**Current WinHTTP proxy settings:**
**Direct access (no proxy server).**

I still don't have the expertise required to help you with that issue, but I suggest you edit the issue formatting to make it easier for maintainers to understand the problem.

Put triple backticks (```) around multi-line code (in that case, both **code** and **error**) and keep the line breaks.
E.g.:

    ```
    code goes here
    including line breaks
    ```

Thanks!

Sorry about the way I posted the question. I'm totally new to Github, still learning.
Thanks for quick tip!

It's okay, Github's markdown can be confusing sometimes.

You're almost there, just need to put line breaks before each triple backtick (```) exactly like I exemplified in my previous comment.

Thanks! But I still have my clarifications, hope someone would help me out.

@timofurrer do you know who can investigate this issue?

No idea, I started checking it myself. Will provide an update here if I find the solution.

My second machine has no proxy enabled, I confirmed the same with `netsh winhttp show proxy`
Output:
`Current WinHTTP proxy settings: Direct access (no proxy server)`

Not sure why the control is getting into `if proxy:` after `proxy = select_proxy(url, proxies)`

So I removed the below lines (288 - 296) from **adapters.py** and created the executable file again. I used this new executable file in the second machine, now the file worked successfully.

```
        if proxy:
            proxy = prepend_scheme_if_needed(proxy, 'http')
            proxy_url = parse_url(proxy)
            if not proxy_url.host:
                raise InvalidProxyURL("Please check proxy URL. It is malformed"
                                      " and could be missing the host.")
            proxy_manager = self.proxy_manager_for(proxy)
            conn = proxy_manager.connection_from_url(url)
        else:
```
I used this as a workaround, please let me know how to fix this permanently.

This looks like a bug in the library, can someone please investigate on this?