Skip to content

Commit 82b75f7

Browse files
fixing import error with h5py and paramiko #987
1 parent fe6917f commit 82b75f7

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ Pachitariu, M., Stringer, C., Schröder, S., Dipoppa, M., Rossi, L. F., Carandin
5959
7. Now run `python -m suite2p` and you're all set.
6060
8. Running the command `suite2p --version` in the terminal will print the install version of suite2p.
6161

62-
For additional dependencies, like NWB and Scanbox support, use the command `python -m pip install suite2p[io]`.
62+
For additional dependencies, like h5py, NWB, Scanbox, and server job support, use the command `python -m pip install suite2p[io]`.
63+
64+
If you are running suite2p on Windows or Linux we recommend installing ScanImage Tiff Reader with `pip install scanimage-tiff-reader`.
6365

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

suite2p/io/h5.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"""
44
import math
55

6-
import h5py
6+
try:
7+
import h5py
8+
HAS_H5PY=True
9+
except:
10+
HAS_H5PY=False
711
import numpy as np
812
import os
913

@@ -25,6 +29,9 @@ def h5py_to_binary(ops):
2529
"Ly", "Lx", ops["reg_file"] or ops["raw_file"] is created binary
2630
2731
"""
32+
if not HAS_H5PY:
33+
raise ImportError("h5py is required for this file type, please 'pip install h5py'")
34+
2835
ops1 = init_ops(ops)
2936

3037
nplanes = ops1[0]["nplanes"]

suite2p/io/server.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
import sys, os, time, glob
55
from pathlib import Path
66
from natsort import natsorted
7-
import paramiko
87
import numpy as np
8+
try:
9+
import paramiko
10+
HAS_PARAMIKO = True
11+
except:
12+
HAS_PARAMIKO = False
913

1014

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

14-
1518
def ssh_connect(host, username, password, verbose=True):
1619
""" from paramiko example """
1720
i = 0
@@ -38,7 +41,6 @@ def ssh_connect(host, username, password, verbose=True):
3841
sys.exit(1)
3942
return ssh
4043

41-
4244
def send_jobs(save_folder, host=None, username=None, password=None, server_root=None,
4345
local_root=None, n_cores=8):
4446
""" send each plane to compute on server separately
@@ -47,6 +49,8 @@ def send_jobs(save_folder, host=None, username=None, password=None, server_root=
4749
for where to save the data
4850
4951
"""
52+
if not HAS_PARAMIKO:
53+
raise ImportError("paramiko required, please 'pip install paramiko'")
5054

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

0 commit comments

Comments
 (0)