Search code examples
installationnetworkxcpython

how to install networkx package on CPython


I have installed CPython [1] on my local machine (macOS Catalina, v. 10.15.4) to speed up computations for function optimize_graph_edit_distance in networkx package. Before, I was running the code on Python3, which takes a lot of time. However, when I run the code with CPython (the alias for CPython is python3), I obtain the following error:

Traceback (most recent call last):
  File "/Users/olha/Desktop/GED_optima.py", line 3, in <module>
    import networkx as nx
ModuleNotFoundError: No module named 'networkx'

I tried python3 -m pip3 install networkx, but I got the following error:

Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
Could not fetch URL https://pypi.org/simple/networkx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/networkx/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement networkx (from versions: none)
ERROR: No matching distribution found for networkx
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

Does anybody knows how to install networkx on CPython?

Thank you!

Olha [1]: https://github.com/python/cpython#documentation


Solution

  • You can install networkx by:

    git clone https://github.com/networkx/networkx.git
    cd networkx
    sudo python setup.py install
    

    Try running the following command (Copied from Mayur Deshmukh's answer to ssl not available):

    python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip