Common Issues and Troubleshooting

Quick fixes for frequent issues when getting started with py3plex. Work through the sections in order (installation → data loading → visualization → performance → algorithms). Apply one fix at a time, then rerun your script before trying the next so you know which change helped.

Installation Issues

“No module named ‘numpy’”

Problem: Import error when trying to use py3plex (ModuleNotFoundError).

Solution: Install numpy first (preferably in a virtual environment to avoid system-wide changes). Upgrading pip often avoids build warnings:

python -m pip install --upgrade pip
python -m pip install numpy
python -m pip install py3plex

Compilation Errors on Windows

Problem: C++ compilation errors during installation on Windows.

Solution: Install Visual C++ Build Tools, then reinstall:

  1. Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/

  2. Install “Desktop development with C++”

  3. Restart your shell, then retry installation

python -m pip install py3plex

“Permission denied” on Linux/macOS

Problem: Permission errors during pip install (for example, [Errno 13] Permission denied or EACCES).

Solution 1: Use a virtual environment (recommended; keeps dependencies isolated):

python3 -m venv py3plex-env
source py3plex-env/bin/activate  # On Windows: py3plex-env\Scripts\activate
python -m pip install --upgrade pip
python -m pip install py3plex

Solution 2: Use pip install with –user flag (if you cannot use venv):

python -m pip install --user py3plex

Old Version Installed

Problem: Changes not reflecting or documentation mentions newer features.

Solution: Verify the installed version, then upgrade to the latest release:

python -m pip show py3plex
python -m pip install --upgrade py3plex
python -m pip show py3plex  # Confirm the version changed

Data Loading Issues

File Not Found Errors

Problem: FileNotFoundError when loading networks.

Solution 1: Confirm the file exists and your working directory is correct (os.getcwd() often differs from the script directory):

import os

print("Current directory:", os.getcwd())
print("File exists:", os.path.exists("data.edgelist"))

Solution 2: Use an absolute path to avoid ambiguity:

from py3plex.core import multinet

network_path = "/absolute/path/to/data.edgelist"
network = multinet.multi_layer_network().load_network(
    network_path, input_type="edgelist", directed=False
)

Solution 3: Build a path relative to the script location (avoids brittle working-directory assumptions):

import os

from py3plex.core import multinet

script_dir = os.path.dirname(os.path.abspath(__file__))
data_path = os.path.join(script_dir, "data", "network.edgelist")
network = multinet.multi_layer_network().load_network(
    data_path, input_type="edgelist", directed=False
)

Empty or Malformed Networks

Problem: Network loads but has no nodes or edges (zero counts).

Solution: Confirm the file contents and chosen input_type match. Pick the loader that matches your columns and delimiter:

# For simple edge lists (source target)
network.load_network("data.txt", input_type="edgelist")

# For multilayer edge lists (source source_layer target target_layer [weight])
network.load_network("data.txt", input_type="multiedgelist")

# Always verify after loading
network.basic_stats()

If counts are still zero:

  • Inspect the first few lines for the expected number of columns and delimiters.

  • Whitespace edge lists have no header; headered CSV input keeps its header. Use source,target,layer,weight or separate endpoint layer columns for CSV.

  • Check that the file is not empty (os.path.getsize).

Visualization Issues

For the plotting examples below, first create a small undirected test network. Replace this with your loaded network when diagnosing your own data:

from py3plex.core import multinet

network = multinet.multi_layer_network(directed=False)
network.add_edges([
    ['Alice', 'layer1', 'Bob', 'layer1', 1.0],
    ['Bob', 'layer1', 'Carol', 'layer1', 2.5],
    ['Alice', 'layer2', 'Carol', 'layer2', 1.0],
], input_type="list")

Visualization Not Showing

Problem: No window appears when calling visualization functions (plots silently finish).

Solution 1: For Jupyter notebooks, enable inline plots:

%matplotlib inline

Solution 2: For scripts, draw through the network wrapper and explicitly show the figure:

import matplotlib.pyplot as plt

network.visualize_network(style="hairball", show=False, verbose=False)

# Explicitly show
plt.show()

Solution 3: Save to file instead of displaying:

import matplotlib.pyplot as plt

plt.figure(figsize=(10, 10))
network.visualize_network(style="hairball", show=False, verbose=False)
plt.savefig("network.png", dpi=150, bbox_inches='tight')
plt.close()

“No Display Found” Error

Problem: Error on headless servers or SSH sessions without X11.

Solution: Use Agg backend for matplotlib so plots are rendered to files:

import matplotlib
matplotlib.use('Agg')  # Set before importing py3plex or pyplot
import matplotlib.pyplot as plt

from py3plex.core import multinet

# A complete headless example; replace with your own network when ready
network = multinet.multi_layer_network(directed=False)
network.add_edges([
    ['Alice', 'layer1', 'Bob', 'layer1', 1.0],
    ['Bob', 'layer1', 'Carol', 'layer1', 2.5],
], input_type="list")
network.visualize_network(style="hairball", show=False, verbose=False)
plt.savefig("output.png")
plt.close()

Blurry or Low-Quality Plots

Problem: Plots look pixelated or blurry.

Solution: Increase DPI and tighten bounding boxes when saving:

plt.savefig("network.png", dpi=300, bbox_inches="tight")

Missing Dependencies

Tip: Feature-specific extras are optional; install only what you need.

“No module named ‘plotly’”

Problem: Interactive visualization features not working.

Solution: Install visualization extras (plotly and related dependencies):

python -m pip install "py3plex[viz]"  # Quotes required on some shells

“No module named ‘infomap’”

Problem: Infomap community detection not working.

Solution: Install Infomap support:

python -m pip install "py3plex[infomap]"  # Quotes required on some shells

Or use alternative community detection methods if you cannot install the extra:

from py3plex.algorithms.community_detection.multilayer_modularity import louvain_multilayer
communities = louvain_multilayer(network, random_state=42)

Performance Issues

Very Slow Loading

Problem: Loading large networks takes too long.

Solution 1: Prefer Arrow/Parquet for large networks to speed up I/O:

# Install Arrow support
python -m pip install "py3plex[arrow]"  # Quotes required on some shells
from py3plex.io import save_to_arrow, load_from_arrow

# Save in efficient format
save_to_arrow(network, "network.arrow")

# Load faster from Arrow
network = load_from_arrow("network.arrow")

Solution 2: Process in chunks or use subnetworks for testing:

# Extract a single layer for testing
layer_1 = network.subnetwork(['layer1'], subset_by="layers")

# Work with the smaller network
layer_1.basic_stats()

Out of Memory Errors

Problem: Python crashes or raises MemoryError with large networks.

Solution: See Performance and Scalability Best Practices for:

  • Memory-efficient loading strategies

  • Batch processing techniques

  • Sparse matrix representations

  • Subnetwork extraction

Algorithm Issues

Community Detection Returns Trivial Results

Problem: Each node in its own community or all nodes in one community (degenerate partition).

Solution: Adjust algorithm parameters and randomness, then compare partitions:

from py3plex.algorithms.community_detection.multilayer_modularity import (
    louvain_multilayer
)

# Try different resolution parameters
partition = louvain_multilayer(
    network,
    gamma=0.5,    # Lower = fewer, larger communities
    omega=1.5,    # Higher = more layer consistency
    random_state=42
)

Random Walk or Embedding Errors

Problem: Random walk or Node2Vec functions fail.

Solution: Ensure the graph is connected before running walks:

import networkx as nx

# Check connectivity
if not nx.is_connected(network.core_network.to_undirected()):
    print("Warning: Network is not connected")

    # Get largest component
    largest = max(nx.connected_components(
        network.core_network.to_undirected()
    ), key=len)

    # Create subgraph
    subgraph = network.core_network.subgraph(largest)

Use the subgraph for embedding or random walk routines if the full network is disconnected. Re-attach results to the full graph only after inspecting coverage.

Docker Issues

Docker Build Fails

Problem: Docker build fails or takes very long.

Solution: Run the build from the current repository root and inspect the plain-text log:

docker build --progress=plain -t py3plex:latest .

Cannot Access Files in Docker

Problem: Docker container can’t see your data files.

Solution: Mount volumes correctly so container paths resolve:

# Mount current directory
docker run --rm -v "$(pwd):/data" py3plex:latest load /data/network.edgelist --info

# On Windows (PowerShell)
docker run --rm -v "${PWD}:/data" py3plex:latest load /data/network.edgelist --info

Adjust the command after the image name to match your workflow (for example, load /data/network.edgelist --info).

See Docker Usage Guide for complete Docker documentation.

Getting Help

If you encounter an issue not covered here:

  1. Search GitHub Issues: https://github.com/SkBlaz/py3plex/issues

  2. Check Documentation: https://skblaz.github.io/py3plex/

  3. Browse Examples: https://github.com/SkBlaz/py3plex/tree/master/examples

When reporting issues, include: * Python version (python --version) * py3plex version (python -m pip show py3plex) * Operating system * Full error traceback * Minimal code to reproduce the problem (or a link to the example you ran)