Skip to content

Commit

Permalink
fixing import error with h5py and paramiko #987
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Jun 22, 2023
1 parent fe6917f commit 82b75f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Pachitariu, M., Stringer, C., Schröder, S., Dipoppa, M., Rossi, L. F., Carandin
7. Now run `python -m suite2p` and you're all set.
8. Running the command `suite2p --version` in the terminal will print the install version of suite2p.

For additional dependencies, like NWB and Scanbox support, use the command `python -m pip install suite2p[io]`.
For additional dependencies, like h5py, NWB, Scanbox, and server job support, use the command `python -m pip install suite2p[io]`.

If you are running suite2p on Windows or Linux we recommend installing ScanImage Tiff Reader with `pip install scanimage-tiff-reader`.

If you have an older `suite2p` environment you can remove it with `conda env remove -n suite2p` before creating a new one.

Expand Down
9 changes: 8 additions & 1 deletion suite2p/io/h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"""
import math

import h5py
try:
import h5py
HAS_H5PY=True
except:
HAS_H5PY=False
import numpy as np
import os

Expand All @@ -25,6 +29,9 @@ def h5py_to_binary(ops):
"Ly", "Lx", ops["reg_file"] or ops["raw_file"] is created binary
"""
if not HAS_H5PY:
raise ImportError("h5py is required for this file type, please 'pip install h5py'")

ops1 = init_ops(ops)

nplanes = ops1[0]["nplanes"]
Expand Down
10 changes: 7 additions & 3 deletions suite2p/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import sys, os, time, glob
from pathlib import Path
from natsort import natsorted
import paramiko
import numpy as np
try:
import paramiko
HAS_PARAMIKO = True
except:
HAS_PARAMIKO = False


def unix_path(path):
return str(path).replace(os.sep, "/")


def ssh_connect(host, username, password, verbose=True):
""" from paramiko example """
i = 0
Expand All @@ -38,7 +41,6 @@ def ssh_connect(host, username, password, verbose=True):
sys.exit(1)
return ssh


def send_jobs(save_folder, host=None, username=None, password=None, server_root=None,
local_root=None, n_cores=8):
""" send each plane to compute on server separately
Expand All @@ -47,6 +49,8 @@ def send_jobs(save_folder, host=None, username=None, password=None, server_root=
for where to save the data
"""
if not HAS_PARAMIKO:
raise ImportError("paramiko required, please 'pip install paramiko'")

if host is None:
raise Exception("No server specified, please edit suite2p/io/server.py")
Expand Down

0 comments on commit 82b75f7

Please sign in to comment.