Closed mauede33 closed 2 years ago
I recommend to follow the official installation instructions of pyapetnet here. There is no need to install everything in a docker container.
Thank you. I will try.
I managed to install miniconda outside of Docker. (pyapetnet) mauramonville@Mauras-MacBook-Pro miniconda3 . It has installed a number of executables: (pyapetnet) mauramonville@Mauras-MacBook-Pro miniconda3 % ls bin 2to3 lzma tclsh8.6 2to3-3.9 lzmadec tic activate lzmainfo toe c_rehash lzmore tput captoinfo ncursesw6-config tqdm chardetect openssl tset clear pip unlzma conda pip3 unxz conda-env pydoc wheel cph pydoc3 wish deactivate pydoc3.9 wish8.6 easy_install python xz idle3 python.app xzcat idle3.9 python3 xzcmp infocmp python3-config xzdec infotocap python3.9 xzdiff lzcat python3.9-config xzegrep lzcmp pythonw xzfgrep lzdiff reset xzgrep lzegrep sqlite3 xzless lzfgrep sqlite3_analyzer xzmore lzgrep tabs lzless tclsh
There is a file (executable ?) named pyapetnet: (pyapetnet) mauramonville@Mauras-MacBook-Pro miniconda3 % ls envs pyapetnet
However, the following instructions generate error messages regardless of the folder where I enter them. I am afraid I cannot interpret the statement 'inside python or ipython' I ran Python and tried the statements:
bash-3.2$ python Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import pyapetnet Traceback (most recent call last): File "
", line 1, in ModuleNotFoundError: No module named 'pyapetnet'>>> print(pyapetnet.version) Traceback (most recent call last): File " ", line 1, in NameError: name 'pyapetnet' is not defined
I am afraid Python cannot see "pyapetnet" . Maybe some soft link is missing.
Waiting for some guidelines. Thank you
Did you start python in a terminal where you activated the virtual environment pyapetnet
?
The detailed steps are:
conda activate pyapetnet
import pyapetnet
If you followed the installation instructions pyapetnet gets installed in a separate virtual env. such that the installed packages don't interfere with other ones.
I thought the problem might be caused by having three python versions installed on my computer. Mac comes with Python2.7 pre-installed.I did not have the guts to remove it after reading the following statement on the internet
“You shouldn’t attempt to remove the pre-installed version of Python provided by Apple, as this may cause your operating system to malfunction”.
Yesterday I had a bad idea of installing Python3.8 as I did not know that Conda would install its own Python3.9.
Today I followed the instructions on the following website. https://www.macupdate.com/app/mac/5880/python/uninstall to uninstall Python3.8. to uninstall Python3.8. Nevertheless, I cannot remove the dead link using the instruction indicated in the above website:
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | tr -d @ | xargs rm*
I prefixed the whole expression with “sudo” as it would not allow me to remove the dead links about Python3.8.
However, I can still see them:
mauramonville@Mauras-MacBook-Pro Python.framework % sudo ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | tr -d @ | xargs rm *
rm: Headers: Permission denied rm: Python: Permission denied rm: Resources: Permission denied rm: Versions: is a directory rm: 2to3: No such file or directory rm: 2to3-3.8: No such file or directory rm: easy_install-3.8: No such file or directory rm: idle3: No such file or directory rm: idle3.8: No such file or directory rm: pip3: No such file or directory rm: pip3.8: No such file or directory rm: pydoc3: No such file or directory rm: pydoc3.8: No such file or directory rm: python3: No such file or directory rm: python3-config: No such file or directory rm: python3.8: No such file or directory rm: python3.8-config: No such file or directory
These pseudo-files are not found but then I can list them:
mauramonville@Mauras-MacBook-Pro Python.framework % ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework' | awk '{print $9}'
2to3 2to3-3.8 easy_install-3.8 idle3 idle3.8 pip3 pip3.8 pydoc3 pydoc3.8 python3 python3-config python3.8 python3.8-config
Anyway, I opened another terminal and made sure the default python is the version installed by Conda, that is Python3.9.1
mauramonville@Mauras-MacBook-Pro ~ % python --version Python 3.9.1
bash-3.2$ python Python 3.9.1 (default, Dec 11 2020, 06:28:49) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.
import pyapetnet Traceback (most recent call last): File "
", line 1, in ModuleNotFoundError: No module named 'pyapetnet'
I can see payapetnet is contained in the folder "envs" inside miniconda
mauramonville@Mauras-MacBook-Pro miniconda3 % pwd /Users/mauramonville/miniconda3 (pyapetnet) mauramonville@Mauras-MacBook-Pro miniconda3 % ls envs pyapetnet
Python3.9 seems to be in folder "bins" inside miniconda
mauramonville@Mauras-MacBook-Pro miniconda3 % pwd /Users/mauramonville/miniconda3 (pyapetnet) mauramonville@Mauras-MacBook-Pro miniconda3 % ls bin 2to3 lzma tclsh8.6 2to3-3.9 lzmadec tic activate lzmainfo toe c_rehash lzmore tput captoinfo ncursesw6-config tqdm chardetect openssl tset clear pip unlzma conda pip3 unxz conda-env pydoc wheel cph pydoc3 wish deactivate pydoc3.9 wish8.6 easy_install python xz idle3 python.app xzcat idle3.9 python3 xzcmp infocmp python3-config xzdec infotocap python3.9 xzdiff lzcat python3.9-config xzegrep lzcmp pythonw xzfgrep lzdiff reset xzgrep lzegrep sqlite3 xzless lzfgrep sqlite3_analyzer xzmore lzgrep tabs lzless tclsh
I delete the miniconda folder and reinstalled it. This is the list of packages installed: (base) mauramonville@Mauras-MacBook-Pro ~ % conda list
#
brotlipy 0.7.0 py39h9ed2024_1003
ca-certificates 2020.12.8 hecd8cb5_0
certifi 2020.12.5 py39hecd8cb5_0
cffi 1.14.4 py39h2125817_0
chardet 3.0.4 py39hecd8cb5_1003
conda 4.9.2 py39hecd8cb5_0
conda-package-handling 1.7.2 py39h9ed2024_1
cryptography 3.3.1 py39hbcfaee0_0
idna 2.10 py_0
libcxx 10.0.0 1
libedit 3.1.20191231 h1de35cc_1
libffi 3.3 hb1e8313_2
ncurses 6.2 h0a44026_1
openssl 1.1.1i h9ed2024_0
pip 20.3.1 py39hecd8cb5_0
pycosat 0.6.3 py39h9ed2024_0
pycparser 2.20 py_2
pyopenssl 20.0.0 pyhd3eb1b0_1
pysocks 1.7.1 py39hecd8cb5_0
python 3.9.1 h88f2d9e_2
python.app 3 py39h9ed2024_0
readline 8.0 h1de35cc_0
requests 2.25.0 pyhd3eb1b0_0
ruamel_yaml 0.15.80 py39h9ed2024_0
setuptools 51.0.0 py39hecd8cb5_2
six 1.15.0 py39hecd8cb5_0
sqlite 3.33.0 hffcf06c_0
tk 8.6.10 hb0a8c7a_0
tqdm 4.54.1 pyhd3eb1b0_0
tzdata 2020d h14c3975_0
urllib3 1.25.11 py_0
wheel 0.36.1 pyhd3eb1b0_0
xz 5.2.5 h1de35cc_0
yaml 0.2.5 haf1e3a3_0
zlib 1.2.11 h1de35cc_3
I reinstalle Miniconda three times. Finally I got to the step Getting started - running your first prediction with pre-trained models". Upon running the suggested prediction I got the following messages: (pyapetnet) mauramonville@Mauras-MacBook-Pro ~ % pyapetnet_predict_from_nifti osem.nii t1.nii S2_osem_b10_fdg_pe2i --show
WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), NOT tf.saved_model.save(). To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory. 2021-07-18 07:13:13.325818: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Traceback (most recent call last): File "/Users/mauramonville/miniconda3/envs/pyapetnet/lib/python3.8/site-packages/nibabel/loadsave.py", line 42, in load stat_result = os.stat(filename) FileNotFoundError: [Errno 2] No such file or directory: 'osem.nii'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mauramonville/miniconda3/envs/pyapetnet/bin/pyapetnet_predict_from_nifti", line 8, in
I guess I should download some data files, but from where?
I have the following models: (pyapetnet) mauramonville@Mauras-MacBook-Pro ~ % pyapetnet_list_models
Model path: /Users/mauramonville/miniconda3/envs/pyapetnet/lib/python3.8/site-packages/pyapetnet/trained_models
190528_paper_bet_10_psf_mlem 200824_mae_osem_nopsf_bet_10 200824_mae_osem_psf_bet_10 S1_osem_b10_fdg S2_osem_b10_fdg_pe2i S3_osem_b10_fdg_pe2i
For details about the models, read /Users/mauramonville/miniconda3/envs/pyapetnet/lib/python3.8/site-packages/pyapetnet/trained_models/model_description.md or the look at the config.json files in the model directories
I tried another prediction but I suspect there are some issues with Tensorflow.
(pyapetnet) mauramonville@Mauras-MacBook-Pro ~ % pyapetnet_predict_from_dicom osem_dcm_dir t1_dcm_dir S2_osem_b10_fdg_pe2i --show
WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), NOT tf.saved_model.save(). To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory.
2021-07-18 07:40:53.609350: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "/Users/mauramonville/miniconda3/envs/pyapetnet/bin/pyapetnet_predict_from_dicom", line 8, in
(1) From the error I think you didn't specify the path of the dicom input data correctly. The first two arguments need to be the correct relative of absolute paths to the input OSEM and T1 dicom folders.
(2) There was another bug in pyapetnet_predict_from_dicom
which was fixed in version 1.1.1. (uploaded today).
So before running another test with the correct dicom paths, you should update your installed pyapetnet version.
E.g. by pip install pyapetnet
which should install the latest available version (v.1.1.1)
I installed it myself on a MAC, and it works perfectly fine.
I followed the instructions posted on HackMD. Folder:/docker/devel.
There is no directory called "OPT" in my file system. I am running Big Sur which is an Apple custom version of Unix BSD.
My Python installation is in /usr/local/bin bash-3.2$ ls /usr/local/bin 2to3 idle3.8 2to3-3.8 kubectl com.docker.cli kubectl.docker docker pip3 docker-compose pip3.8 docker-compose-v1 pydoc3 docker-credential-desktop pydoc3.8 docker-credential-ecr-login python docker-credential-osxkeychain python3 easy_install-3.8 python3-config hub-tool python3.8 hyperkit python3.8-config idle3 vpnkit
Where am I supposed to go from here? Thank you