tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.34k stars 1.61k forks source link

ModuleNotFoundError: No module named 'tensorlayer' after installing tensorlayer #1018

Closed tobimichigan closed 3 years ago

tobimichigan commented 5 years ago

New Issue Checklist

Issue Description

[ModuleNotFoundError: No module named 'tensorlayer' after installing tensorlayer occurs when trying to run one of the git examples]

Reproducible Code

[>>> import array

import hashlib import os import time

import numpy as np

import tensorflow as tf import tensorlayer as tl Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tensorlayer' from tensorlayer.layers import Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tensorlayer' from tensorlayer.models import Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tensorlayer'

]

# ======================================================== #
Requirement already satisfied: tensorlayer in ./.local/lib/python3.7/site-packages (2.1.0)
Requirement already satisfied: numpy<1.17,>=1.16 in ./.local/lib/python3.7/site-packages (from tensorlayer) (1.16.4)
Requirement already satisfied: scipy==1.2.1 in ./.local/lib/python3.7/site-packages (from tensorlayer) (1.2.1)
Requirement already satisfied: wrapt==1.11.1 in ./.local/lib/python3.7/site-packages (from tensorlayer) (1.11.1)
Requirement already satisfied: imageio==2.5.0 in ./.local/lib/python3.7/site-packages (from tensorlayer) (2.5.0)
Requirement already satisfied: progressbar2==3.39.3 in ./.local/lib/python3.7/site-packages (from tensorlayer) (3.39.3)
Requirement already satisfied: h5py>=2.9 in ./.local/lib/python3.7/site-packages (from tensorlayer) (2.9.0)
Requirement already satisfied: cloudpickle>=0.8.1 in ./.local/lib/python3.7/site-packages (from tensorlayer) (1.2.1)
Requirement already satisfied: scikit-image==0.15.0 in ./.local/lib/python3.7/site-packages (from tensorlayer) (0.15.0)
Requirement already satisfied: scikit-learn==0.21.0 in ./.local/lib/python3.7/site-packages (from tensorlayer) (0.21.0)
Requirement already satisfied: requests==2.21.0 in /usr/lib/python3/dist-packages (from tensorlayer) (2.21.0)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from imageio==2.5.0->tensorlayer) (5.4.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from progressbar2==3.39.3->tensorlayer) (1.12.0)
Requirement already satisfied: python-utils>=2.3.0 in ./.local/lib/python3.7/site-packages (from progressbar2==3.39.3->tensorlayer) (2.3.0)
Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in ./.local/lib/python3.7/site-packages (from scikit-image==0.15.0->tensorlayer) (3.1.1)
Requirement already satisfied: PyWavelets>=0.4.0 in ./.local/lib/python3.7/site-packages (from scikit-image==0.15.0->tensorlayer) (1.0.3)
Requirement already satisfied: networkx>=2.0 in ./.local/lib/python3.7/site-packages (from scikit-image==0.15.0->tensorlayer) (2.3)
Requirement already satisfied: joblib>=0.11 in ./.local/lib/python3.7/site-packages (from scikit-learn==0.21.0->tensorlayer) (0.13.2)
Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python3/dist-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.15.0->tensorlayer) (2.7.3)
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.15.0->tensorlayer) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./.local/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.15.0->tensorlayer) (2.4.0)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.15.0->tensorlayer) (1.1.0)
Requirement already satisfied: decorator>=4.3.0 in ./.local/lib/python3.7/site-packages (from networkx>=2.0->scikit-image==0.15.0->tensorlayer) (4.4.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from kiwisolver>=1.0.1->matplotlib!=3.0.0,>=2.0.0->scikit-image==0.15.0->tensorlayer) (40.8.0)

# ======================================================== #

Besides, when I run "conda list@,  from the terminal, I get the following:

# Name                    Version                   Build  Channel
_tflow_select             2.1.0                       gpu    anaconda
absl-py                   0.7.1                    py36_0    anaconda
astor                     0.7.1                    py36_0    anaconda
blas                      1.0                         mkl    anaconda
bleach                    1.5.0                    py36_0    anaconda
c-ares                    1.15.0               h7b6447c_1    anaconda
ca-certificates           2019.5.15                     0    anaconda
certifi                   2019.6.16                py36_0    anaconda
cudatoolkit               9.0                  h13b8566_0    anaconda
cudnn                     7.6.0                 cuda9.0_0    anaconda
cupti                     9.0.176                       0    anaconda
gast                      0.2.2                    py36_0    anaconda
grpcio                    1.16.1           py36hf8bcb03_1    anaconda
h5py                      2.9.0            py36h7918eee_0    anaconda
hdf5                      1.10.4               hb1b8bf9_0    anaconda
html5lib                  0.9999999                py36_0    anaconda
intel-openmp              2019.4                      243    anaconda
keras-applications        1.0.8                      py_0    anaconda
keras-preprocessing       1.1.0                      py_1    anaconda
libedit                   3.1.20181209         hc058e9b_0    anaconda
libffi                    3.2.1                h4deb6c0_3    anaconda
libgcc-ng                 9.1.0                hdf63c60_0    anaconda
libgfortran-ng            7.3.0                hdf63c60_0    anaconda
libprotobuf               3.8.0                hd408876_0    anaconda
libstdcxx-ng              9.1.0                hdf63c60_0    anaconda
markdown                  3.1.1                    py36_0    anaconda
mkl                       2019.4                      243    anaconda
mkl_fft                   1.0.12           py36ha843d7b_0    anaconda
mkl_random                1.0.2            py36hd81dba3_0    anaconda
mock                      3.0.5                    py36_0    anaconda
ncurses                   6.1                  he6710b0_1    anaconda
numpy                     1.16.4           py36h7e9f1db_0    anaconda
numpy-base                1.16.4           py36hde5b4d6_0    anaconda
openssl                   1.1.1                h7b6447c_0    anaconda
pip                       19.1.1                   py36_0    anaconda
protobuf                  3.8.0            py36he6710b0_0    anaconda
python                    3.6.8                h0371630_0    anaconda
readline                  7.0                  h7b6447c_5    anaconda
scipy                     1.2.1            py36h7c811a0_0    anaconda
setuptools                41.0.1                   py36_0    anaconda
six                       1.12.0                   py36_0    anaconda
sqlite                    3.28.0               h7b6447c_0    anaconda
tensorboard               1.14.0           py36hf484d3e_0    anaconda
tensorflow-estimator      1.13.0                     py_0    anaconda
tensorflow-gpu            1.5.0                         0    anaconda
tensorflow-gpu-base       1.5.0            py36h8a131e3_0    anaconda
tensorflow-tensorboard    1.5.1            py36hf484d3e_1    anaconda
termcolor                 1.1.0                    py36_1    anaconda
tk                        8.6.8                hbc83047_0    anaconda
werkzeug                  0.15.4                     py_0    anaconda
wheel                     0.33.4                   py36_0    anaconda
xz                        5.2.4                h14c3975_4    anaconda
zlib                      1.2.11               h7b6447c_3    anaconda

# ======================================================== #
###### THIS CODE IS AN EXAMPLE, REPLACE WITH YOUR OWN ######
# ======================================================== #

@JingqingZ ..but I got this hint after running pip3 install tensorlayer "the scripts f2py, f2py3 and f2py3.7 are installed in '/home/hgh/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. The scripts imageio_download_bin and imageio_remove_bin are installed in '/home/hgh/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. The script skivi is installed in '/home/hgh/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location." How do I do this, I mean add this to my path? Could this be the problem why tensorlayer cannot be found? It seems as if tensorlayer is not on the list. I was sure to activate conda env created for tensorlayer, but tensorlayer seems to be missing. Or installed elsewhere after I ran pip3 install tensorlayer.

JingqingZ commented 5 years ago

Hi, it seems tensorlayer is not in your conda environment.

To add a path to the PATH, you need to find ~/.bashrc and add the path /home/hgh/.local/bin into it.

Please check https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix

se7enXF commented 5 years ago

@tobimichigan

Different python environment error

Obviously, it is caused by different python environment. If you use conda make sure that you are always in conda environment. Check your command line if you are using correct environment when you use pip or python.

tobimichigan commented 5 years ago

@JingqingZ & @se7enXF , for the record, I use the following on my system running, flawlessly: keras gpu [all the modules for scientific computation] tensorflow_gpu[with all the features for computation] pytorch_gpu[with all the features for computation]

My question is why should Tensorlayer be finding it difficult to be found in an environment that other python modules find so easily to run?

se7enXF commented 5 years ago

@tobimichigan

Because you install tensorlayer in python3.7, but install keras and tensorflow in conda python3.6. From your upper information:

# In your system python3.7
Requirement already satisfied: tensorlayer in ./.local/lib/python3.7/site-packages (2.1.0)   

# In your conda python3.6
conda list: 
python                    3.6.8                h0371630_0    anaconda  
tensorflow-gpu            1.5.0                         0    anaconda  
keras-applications        1.0.8                      py_0    anaconda 
...   

It`s your fault to install tensorlayer in the wrong place.
To solve your problem, activate the conda environment and then use pip to install tensorlayer.

tobimichigan commented 5 years ago

@JingqingZ & @se7enXF, I would suggest you made installation on a local machine more clearer than the current documentation indicates, I think its rather confusing. You have a good framework with a good potential. Tensorlayer is good if well maintained. I don't think the problem was my environment. Like I said, other py modules work in the same without any flaws. What I did to resolve this issue was to go on the cloud and installed tensor-layer. I am still testing your framework and will definitely post any issue that needs attention. In the nearest future, I would love to be part of your development team.