Skip to content

Instantly share code, notes, and snippets.

@vsoch
Last active May 9, 2018 07:56
Show Gist options
  • Save vsoch/dca1abe2baf373e5e2b451a0baf8591d to your computer and use it in GitHub Desktop.
Save vsoch/dca1abe2baf373e5e2b451a0baf8591d to your computer and use it in GitHub Desktop.
Natalia's Nipype Issue
[sudo] password for vanessa: 
Using container recipe deffile: Singularity.swist
Sanitizing environment
Adding base Singularity environment to container
Docker image path: index.docker.io/nipype/nipype:latest
Cache folder set to /root/.singularity/docker
[25/25] |===================================| 100.0% 
Exploding layer: sha256:3e17c6eae66cd23c59751c8d8f5eaf7044e0611dc5cebb12b1273be07cdac242.tar.gz
Exploding layer: sha256:a0d4ad639aa3e5db2d833ff8a8faf2c50d800dc4c3fc6c8699e7402218e10a0c.tar.gz
Exploding layer: sha256:3b90a338012a2cf5d577f4f9aec0456e94da298547a7d696a4795c312465c215.tar.gz
Exploding layer: sha256:ec586d219c2772e19be215819780f02fb6e170d9c94513c070082fbf40173a7e.tar.gz
Exploding layer: sha256:2334caa7934b0d8c0b42f9f6c1c03aff6b45fbd84b125094be089baf1f28c48c.tar.gz
Exploding layer: sha256:f634a6f7e8c1b6ca673626bbbf77fa889b04b06cd20bdef21451c65216e5fc6b.tar.gz
Exploding layer: sha256:ed6f5ff4037cb0b18c67c0db8f57da464e9266554030d48f300fdb5d9978328e.tar.gz
Exploding layer: sha256:7815a5e3deeb3338a4d48bd599a59ae8f5d86da85d3b1d06128a83bc1c2ddf77.tar.gz
Exploding layer: sha256:7e97dbd3ea5069976421800758cc73841997f5599a566b1a505c3dfbd4c3d4ec.tar.gz
WARNING: Warning handling tar header: Can't create 'usr/lib/x86_64-linux-gnu/libgsl.so.19'
Exploding layer: sha256:c8997298f6d6a13907819fcf911de8d779d4eda55752c26e648ce4f3ab6db02b.tar.gz
Exploding layer: sha256:74a9f4f37fd936c2b59f9bfa0792ecab96bd341179b518ad7ce54efbe95b6c47.tar.gz
Exploding layer: sha256:ca1d7bc55025670518c17e2786ad6f3eb90313074cd8705bb1be8dbcf80ad8e3.tar.gz
WARNING: Warning reading tar header: Ignoring malformed pax extended attribute
Exploding layer: sha256:d9ca35ac248f50a4c5f9277efcde2f078d626863eae397b7417909a116641c97.tar.gz
Exploding layer: sha256:f78c5310186301b4014d99f83242c3fdb9dfdbb7e23a1a585728a34a587d48c3.tar.gz
Exploding layer: sha256:9b771f4a580c21f733ea8b872be3d3743a5b1c965a2da7723d6177ad6b2d65f4.tar.gz
Exploding layer: sha256:4df2c5c940c599891dfe8f0a66fe02779f0124005097ffc1164814ea3f38a9e3.tar.gz
Exploding layer: sha256:0c679ec5f065b817c4667fc0d7bac276366a550fd50d2ae3462f2cf6c48b8e73.tar.gz
Exploding layer: sha256:5ad06149d14c2bd77f9742f603d31b9d95cd3a619b84580b8dff8eb5f279ab45.tar.gz
Exploding layer: sha256:684e77d490a50f9166d426b8d6e4db2821149463b29067f931bbafa1a2b96e9e.tar.gz
Exploding layer: sha256:987ff6bf29f6004abd867f83687ba0fbc8ec969aa53a752a6474f8bfd7d971bf.tar.gz
Exploding layer: sha256:700ac25c60a530ad25a8d70cb446e0dd68dc04ca8ce7ebc98bc9c1e8f0e8cc8e.tar.gz
Exploding layer: sha256:781decf2dfdd168a7bd94fb679797f4363af260cfcfac85e94bbdb58fdf7d28c.tar.gz
Exploding layer: sha256:14eea3ffef97be92dcda199b9e0a9801a1019143aff0c77a98dc8f43f957e7d3.tar.gz
Exploding layer: sha256:427f6b513d614142bc80c6544d81fbbf731b63add4b9a2ab76b7e023071f7f4f.tar.gz
Exploding layer: sha256:1072210b8b1dcc7b5b2ff1f627bc44b8b4c58215f34b950b07fef962d784ae0f.tar.gz
Exploding layer: sha256:37d208158a66278d1f67301ae81d0c0dbc02d97d176cd7d461afe4cc2d9a6b0d.tar.gz
Running post scriptlet
+ apt-get update
Get:2 http://security.debian.org stretch/updates InRelease [94.3 kB]
Ign:1 http://cdn-fastly.deb.debian.org/debian stretch InRelease     
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]                             
Get:5 http://neuro.debian.net/debian stretch InRelease [24.0 kB]                                              
Get:4 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]                                                    
Get:6 http://neuro.debian.net/debian data InRelease [25.7 kB]                                            
Get:7 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]                               
Get:8 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [12.1 kB]
Get:9 http://security.debian.org stretch/updates/contrib amd64 Packages [1773 B]                                                 
Get:10 http://neuro.debian.net/debian stretch/main amd64 Packages [186 kB]                                                       
Get:11 http://cdn-fastly.deb.debian.org/debian stretch/contrib amd64 Packages [61.0 kB]                    
Get:12 http://security.debian.org stretch/updates/non-free amd64 Packages [1208 B]          
Get:13 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9530 kB]                               
Get:14 http://neuro.debian.net/debian stretch/contrib amd64 Packages [17.9 kB] 
Get:15 http://security.debian.org stretch/updates/main amd64 Packages [471 kB]            
Get:16 http://neuro.debian.net/debian stretch/non-free amd64 Packages [9036 B]                                                               
Get:17 http://neuro.debian.net/debian data/main amd64 Packages [6308 B]                                                                       
Get:18 http://neuro.debian.net/debian data/non-free amd64 Packages [6106 B]                                                                  
Get:19 http://cdn-fastly.deb.debian.org/debian stretch/non-free amd64 Packages [92.8 kB]                                                         
Fetched 10.8 MB in 12s (847 kB/s)                                                                                                                
Reading package lists... Done
+ apt-get install nano
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  spell
The following NEW packages will be installed:
  nano
0 upgraded, 1 newly installed, 0 to remove and 48 not upgraded.
Need to get 485 kB of archives.
After this operation, 2092 kB of additional disk space will be used.
Get:1 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 nano amd64 2.7.4-1 [485 kB]
Fetched 485 kB in 1s (261 kB/s)
Selecting previously unselected package nano.
(Reading database ... 33395 files and directories currently installed.)
Preparing to unpack .../nano_2.7.4-1_amd64.deb ...
Unpacking nano (2.7.4-1) ...
Setting up nano (2.7.4-1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
+ CONDA_ENV=/opt/conda/bin
+ export PATH=/opt/conda/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+ chmod -R 777 /opt/conda/bin
+ conda activate neuro

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with

    $ echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

    $ sudo ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh

The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH.  To do so, run

    $ conda activate

in your terminal, or to put the base environment on PATH permanently, run

    $ echo "conda activate" >> ~/.bashrc

Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file.  You should manually remove the line that looks like

    export PATH="/opt/conda/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^


ABORT: Aborting with RETVAL=255
Cleaning up...

Thanks for waiting! I've made a repository that contains the steps I used to install the Vagrant VM (if that's useful) and the Singularity recipe.

Just to reiterate what the issue is:

  • I'm building a Nipype image from the recipe. Within %post, I'd like to install two additional packages (seaborn and pybids) into the "neuro" conda environment.
  • However, when I try to activate the neuro environment within %post ("source activate neuro"), I keep getting an error message saying that the command "source" is not found.
  • I'd like to run the commands in %post with bash, but am not sure where to specify it.

See Potential issue in build:

WARNING: Warning handling tar header: Can't create 'usr/lib/x86_64-linux-gnu/libgsl.so.19'

Build and Usage

sudo singularity build swist Singularity.swist
...
Singularity swist:~/Documents/Dropbox/Code/srcc/for-singularity/swist_fmri_image>   . /opt/conda/bin/activate neuro
(neuro) Singularity swist:~/Documents/Dropbox/Code/srcc/for-singularity/swist_fmri_image> python
Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:39:56) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import seaborn
>>> import nipype
/opt/conda/envs/neuro/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
 from ._conv import register_converters as _register_converters
>>> import bids
>>>
Bootstrap: docker
From: nipype/nipype:latest
# This is the adjusted (fixed) build recipe for the issue above.
# sudo singularity build swist Singularity.swist
%labels
Maintainer Natalia
Version v1.0
%environment
. /opt/conda/bin/activate neuro
%post
# Install nano
apt-get update && apt-get install -y nano
# Install into conda environment
. /opt/conda/bin/activate neuro &&
/opt/conda/bin/conda install --name neuro -y seaborn &&
/opt/conda/envs/neuro/bin/pip install pybids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment