Set up Coding Environment#
This notebook will ensure that your coding environment is set up for the interactive activities in this textbook. You do not need to worry about these requirements if you are running code on the Dandihub, as recommended in “How to use this book”. You can simply ignore this page and get on with the data!
Package Requirements#
If you’re not running the code on the Dandihub, then we have to ensure that your coding environment has all of the proper packages installed. The packages required are:
numpy==1.23.1
dandi==0.45.1
h5py==2.10.0
The code below will ensure that you have these packages or newer.
First, we need to ensure that you have the DANDI
client installed in your coding environment. The cell below will try to import DANDI. If you have an old version of DANDI, it will prompt you to install a newer version. Type “Y” if you would like to install a new version (this is recommended). If you don’t have DANDI at all, it will install the most recent version.
# This will ensure that the correct version of dandi is installed
try:
import dandi
if dandi.__version__>='0.45.1':
print('Updated DANDI installed.')
else:
response = input('Old version of DANDI installed. Would you like to install a newer version of DANDI? (Y/N)')
if response.upper() == 'Y':
!pip install --upgrade dandi
except ImportError as e:
!pip install dandi
Updated DANDI installed.
Next, we’ll check for pyNWB, the python package for NWB.
# Check for pywnb
try:
import pynwb
print('pyNWB installed.')
except ImportError as e:
!pip install pwynb
pyNWB installed.
Finally, also need to make sure you have the correct version of NumPy.
try:
import numpy
if numpy.__version__>='1.23.1':
print('Updated NumPy installed.')
else:
response = input('Old version of NumPy installed. Would you like to install a newer version of NumPy? (Y/N)')
if response.upper() == 'Y':
!pip install --upgrade numpy
except ImportError as e:
!pip install numpy
Updated NumPy installed.
First things first, let’s make sure you have the AllenSDK installed. See the Allen Institute website for information on installing it, otherwise, the cell below will do it for you.
# This will ensure that the AllenSDK is installed.
# If not, it will install it for you.
try:
import allensdk
if allensdk.__version__ == '2.13.6':
print('allensdk already installed.')
else:
response = input('Old version of AllenSDK installed. Would you like to install a newer version? (Y/N)')
if response.upper() == 'Y':
!pip install --upgrade allensdk
except ImportError as e:
!pip install allensdk
---------------------------------------------------------------------------
StdinNotImplementedError Traceback (most recent call last)
Cell In[4], line 8
6 print('allensdk already installed.')
7 else:
----> 8 response = input('Old version of AllenSDK installed. Would you like to install a newer version? (Y/N)')
9 if response.upper() == 'Y':
10 get_ipython().system('pip install --upgrade allensdk')
File ~/anaconda3/envs/jb/lib/python3.11/site-packages/ipykernel/kernelbase.py:1201, in Kernel.raw_input(self, prompt)
1199 if not self._allow_stdin:
1200 msg = "raw_input was called, but this frontend does not support input requests."
-> 1201 raise StdinNotImplementedError(msg)
1202 return self._input_request(
1203 str(prompt),
1204 self._parent_ident["shell"],
1205 self.get_parent("shell"),
1206 password=False,
1207 )
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.