简体   繁体   中英

ModuleNotFoundError: No module named 'tf_slim' despite installing

I'd like to run call_variants.py from deepvariant . I was struggling for hours ans hours installing cuda, tensorflow etc... Unfortunately I ran into a problem and I don't know what to do. Let's start from the beginning:

conda create --name tf tensorflow
conda activate tf
python --version
Python 3.7.9
python3 -c 'import tensorflow as tf; print(tf.__version__)'
2.3.0

Now I tried to run the command:

python ${h_dir}/deepvariant/binaries/DeepVariant/1.0.0/DeepVariant-1.0.0/call_variants.zip \
--outfile ${test_dir}/test.gz \
--examples ${ex_dir}/ex_test.gz --checkpoint $model

I got:

Traceback (most recent call last):
  File "/tmp/Bazel.runfiles_i55m5mpq/runfiles/com_google_deepvariant/deepvariant/call_variants.py", line 57, in <module>
    from deepvariant import modeling
  File "/tmp/Bazel.runfiles_i55m5mpq/runfiles/com_google_deepvariant/deepvariant/modeling.py", line 51, in <module>
    import tf_slim
ModuleNotFoundError: No module named 'tf_slim'

So of course I decided to install it:

pip install tf_slim
Collecting tf_slim
  Using cached tf_slim-1.1.0-py2.py3-none-any.whl (352 kB)
Requirement already satisfied: absl-py>=0.2.2 in ./anaconda3/envs/tf/lib/python3.7/site-packages (from tf_slim) (0.11.0)
Requirement already satisfied: six in ./anaconda3/envs/tf/lib/python3.7/site-packages (from absl-py>=0.2.2->tf_slim) (1.15.0)
Installing collected packages: tf-slim
Successfully installed tf-slim-1.1.0

However:

python3 -c 'import tf_slim as slim; print(slim.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'tf_slim' has no attribute '__version__'

An of course ModuleNotFoundError: No module named 'tf_slim' after running the command. So maybe install with conda?

conda install -c conda-forge tf-slim

But it didn't help at all... I have no clue what to do next, looking forward to any ideas!

Edit: When I run something like this:

try:
    import tf_slim as slim
    print("module 'tf_slim' is installed")
except ModuleNotFoundError:
    print("module 'tf_slim' is not installed")

python test.py
module 'tf_slim' is installed

But after command, still ModuleNotFoundError: No module named 'tf_slim'

¯_(ツ)_/¯

Ok, I think I got it. As you may see I used conda to create enviroment for tensorflow. As I read, this procedure is recommended, otherwise you may encounter something like ModuleNotFoundError: No module named 'tensorflow' which has been described here . So what I did? I deactivated and removed any conda enviroment and I decided to run my command without it, just in terminal. First, however I run the command with python3 then I occured same error that's ModuleNotFoundError: No module named 'tf_slim' and I installed it with pip3 install tf_slim and it worked. Next I run deepvariant script postprocess_variants.py and I had the same problem with altair module but I did the same and the both commands worked!

Just uninstall tf_slim and then again install the tf_slim package, it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM