Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import predict function #12

Closed
richelbilderbeek opened this issue May 25, 2020 · 4 comments
Closed

Cannot import predict function #12

richelbilderbeek opened this issue May 25, 2020 · 4 comments

Comments

@richelbilderbeek
Copy link
Contributor

Dear MHCnuggets maintainer,

MHCnuggests appears awesome! Sadly, however, I cannot even get it to be imported. Because there is no CI (#11), I do not dare assume the problem is on my side (although I predict it is).

Here I install MHCnuggets ...

sudo pip3 install mhcnuggets 

... which results in showing I already did so.

Requirement already satisfied: mhcnuggets in /usr/local/lib/python3.8/dist-packages (2.3.2)
Requirement already satisfied: keras in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (2.3.1)
Requirement already satisfied: tensorflow in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (2.2.0)
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (0.23.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (1.18.4)
Requirement already satisfied: scipy in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (1.4.1)
Requirement already satisfied: pandas in /usr/local/lib/python3.8/dist-packages (from mhcnuggets) (1.0.3)
Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.8/dist-packages (from keras->mhcnuggets) (1.0.8)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.8/dist-packages (from keras->mhcnuggets) (1.1.2)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from keras->mhcnuggets) (5.3.1)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from keras->mhcnuggets) (1.14.0)
Requirement already satisfied: h5py in /usr/local/lib/python3.8/dist-packages (from keras->mhcnuggets) (2.10.0)
Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (0.9.0)
Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (1.29.0)
Requirement already satisfied: tensorflow-estimator<2.3.0,>=2.2.0 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (2.2.0)
Requirement already satisfied: gast==0.3.3 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (0.3.3)
Requirement already satisfied: astunparse==1.6.3 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (1.6.3)
Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (1.1.0)
Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (1.12.1)
Requirement already satisfied: protobuf>=3.8.0 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (3.12.1)
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /usr/lib/python3/dist-packages (from tensorflow->mhcnuggets) (0.34.2)
Requirement already satisfied: google-pasta>=0.1.8 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (0.2.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (3.2.1)
Requirement already satisfied: tensorboard<2.3.0,>=2.2.0 in /usr/local/lib/python3.8/dist-packages (from tensorflow->mhcnuggets) (2.2.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.8/dist-packages (from scikit-learn->mhcnuggets) (2.0.0)
Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.8/dist-packages (from scikit-learn->mhcnuggets) (0.15.1)
Requirement already satisfied: pytz>=2017.2 in /usr/lib/python3/dist-packages (from pandas->mhcnuggets) (2019.3)
Requirement already satisfied: python-dateutil>=2.6.1 in /usr/lib/python3/dist-packages (from pandas->mhcnuggets) (2.7.3)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from protobuf>=3.8.0->tensorflow->mhcnuggets) (45.2.0)
Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.8/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (1.15.0)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.8/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (0.4.1)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.8/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (1.6.0.post3)
Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.8/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (1.0.1)
Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.8/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (3.2.2)
Requirement already satisfied: requests<3,>=2.21.0 in /usr/lib/python3/dist-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (2.22.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.8/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (0.2.8)
Requirement already satisfied: rsa<4.1,>=3.1.4 in /usr/local/lib/python3.8/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (4.0)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.8/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (4.1.0)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.8/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (1.3.0)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.8/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (0.4.8)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/lib/python3/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.3.0,>=2.2.0->tensorflow->mhcnuggets) (3.1.0)

Then I want to run this Python script, which is the first line from the example notebook):

from mhcnuggets.src.predict import predict

Running this from a shell:

python3 mhcnuggets.py

Results in:

Traceback (most recent call last):
  File "mhcnuggets.py", line 1, in <module>
    from mhcnuggets.src.predict import predict
  File "/home/richel/mhcnuggets.py", line 1, in <module>
    from mhcnuggets.src.predict import predict
ModuleNotFoundError: No module named 'mhcnuggets.src'; 'mhcnuggets' is not a package

Where is the error?

@richelbilderbeek
Copy link
Contributor Author

richelbilderbeek commented May 25, 2020

Copied from here:

Hi Richel,

Thank you for your question. I see a couple potential solutions here.

  1. It seems like your python is not recognizing your mhcnuggets's installation, that's why it is errorring out on the first step. You should probably check whether your "./bashrc" file has point your export paths to the right libraries or how your python environments are set up. For example, if you are calling one python2 environment, but mhcnuggets is installed under your python3 environment, you won't be able to call that package. You could find out more with this link here: https://stackoverflow.com/questions/53952214/how-can-i-find-out-which-python-virtual-environment-i-am-using.

  2. We built MHCnuggets mostly on python2 instead of python3. Although we built it to be indifferent to python versions, it could be one aspect of your problem (probably not the main issue here).

Hope my answer helps you.

Melody

@richelbilderbeek
Copy link
Contributor Author

Hi @XiaoshanShao,

Again, thanks for your reply. Here I demonstrate that, AFAICS, the Python version does not matter:

Show my Python script file again:

cat mhcnuggets.py

Results in this one line:

from mhcnuggets.src.predict import predict

Running it with Python2:

python2 mhcnuggets.py 

results in the same error:

Traceback (most recent call last):
  File "mhcnuggets.py", line 1, in <module>
    from mhcnuggets.src.predict import predict
  File "/home/richel/mhcnuggets.py", line 1, in <module>
    from mhcnuggets.src.predict import predict
ImportError: No module named src.predict

Can you reproduce the bug, or does it work cleanly on your computer?

@XiaoshanShao
Copy link
Contributor

Hi @richelbilderbeek ,

We use MHCnuggets daily, and I just uninstalled/reinstalled it through pip. It doesn't appear to have any issue for me. From your bug, it does seem to me that it is an environment issue. You python environment is not finding your mhcnuggets package. Here is another link to help you set up your environment: https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory.

If you don't want to deal with all the environment issues, you could use our docker version of MHCnuggets, and the instructions are here: https://github.com/KarchinLab/mhcnuggets/wiki/MHCnuggets-container-with-Jupyter-Notebook-interface.

Or you could just clone the whole package from our github site, and use the source code as python scripts since everything is open source.

Melody

@richelbilderbeek
Copy link
Contributor Author

Hi Melody, thanks for confirming the problem is on my side (I assume you ran the script as well)!

use the source code as python scripts since everything is open source.

Yup, that is exactly what I am doing 😎 👍

OK, will close this Issue then, unless I have some evidence something is wrong. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants