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

ModuleNotFoundError: No module named 'ctpnet' #16

Open
amber4mint opened this issue Apr 28, 2020 · 13 comments
Open

ModuleNotFoundError: No module named 'ctpnet' #16

amber4mint opened this issue Apr 28, 2020 · 13 comments

Comments

@amber4mint
Copy link

Hi,

When I went through the demo analysis and tried to import the pretrained model, I got this error message below:

model_file_path="C:/Users/User/Documents/cTPnet_weight_24"
data_type='Seurat3'
demo = CreateSeuratObject(demo_data)
demo = cTPnet(demo,data_type,model_file_path)

Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'ctpnet'

Would you have any suggestion for this?

thanks in advance

@zhouzilu
Copy link
Owner

zhouzilu commented May 5, 2020

Hi there,

Just want to confirm, have you install the python package cTPnet with command "pip install cTPnet"? Have you tried to update the package to the most up to date version?

Please let me know if this doesn't solve your problem.

-Z

@amber4mint
Copy link
Author

Hi,

Yes, I've installed the latest version of python package cTPnet, but this problem keep happening.

@zhouzilu
Copy link
Owner

zhouzilu commented May 6, 2020

Sorry for the trouble. Let me re-test it today.
-Z

@zhouzilu
Copy link
Owner

zhouzilu commented May 7, 2020

Hi there, I just reinstall and tested the package again and it works fine. Just want to ask a few questions to help me debug.
(1) Which system are you using?
(2) Did you set up a virtual environment?
(3) If you used a virtual environment, did you call use_virtualenv right after load "reticulate" library?

-Z

@amber4mint
Copy link
Author

Hi,

Sorry for late reporting, and thank you for replying and helping.

(1) I run cTPnet in R in Windows, but the python package cTPnet was installed in Linux. Because I've reinstalled and tried to launch cTPnet in R these days, and I found that I can't install the python package cTPnet in Python in Windows.
(2) Whenever I run cTPnet in R in Windows, I set up a virtual environment by using "use_virtualenv" function.
(3) After loading "reticulate" library, I call "use_virtualenv" and it still reported the same error message.

@zhouzilu
Copy link
Owner

zhouzilu commented May 14, 2020

Hi,
Sorry I got a little confused. Did you install the python package in Linux but try to call it in R in windows? Did you have two system installed in the same computer?

In addition, I have tested cTPnet python package in Windows and it works fine. Which version of Python were you using?

You can install new python version here https://www.python.org/downloads/windows/ .
If you don't want to use a virtual environment, it should be fine to. Try python get-pip.py to get pip installed and then pip install cTPnet to install the cTPnet python package.

Please let me know if this approach solves your problem.

Best,
Zilu

@amber4mint
Copy link
Author

Hi,
(1) yes, I tried to call cTPnet in R in windows after installing it in Linux. (because in the second time that I uninstalled and reinstalled cTPnet in both systems, it worked in Linux but failed in Windows.)
(2) yes, I have Windows and Linux installed in the same computer. But I use Linux by MobaXterm.
(3) Now, I've installed the latest version of Python (3.8.3).
(4) When I used python get-pip.py to get pip installed, and I got an error message: python: can't open file 'get-pip.py': [Errno 2] No such file or directory.
Then I tried pip install cTPnet, I got the same error message that I got in the second time testing: ERROR: Could not find a version that satisfies the requirement torch>=0.4.1 (from cTPnet) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch>=0.4.1 (from cTPnet)

Thank you

@zhouzilu
Copy link
Owner

Hi,

Sorry for the confusion. I think your pip has installed. For windows, you have to install torch differently. Please try the following command conda install pytorch torchvision cpuonly -c pytorch. Then you should be able to install cTPnet python package with pip install cTPnet.

Best,
Zilu

@amber4mint
Copy link
Author

Hi,

Thank you for the advice, I successfully installed cTPnet python package in windows.
But when I tried to call cTPnet in R in windows, the same error message still was reported:

`> model_file_path="C:/Users/User/Documents/cTPnet_weight_24"

data_type='Seurat3'
demo = CreateSeuratObject(demo_data)
demo = cTPnet(demo,data_type,model_file_path)
Start data preprocessing...
Start imputation. Running python ...
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'ctpnet'`

Thank you

@zhouzilu
Copy link
Owner

Hi,

Apologize for the late reply. My advice is to make sure that the Python PATH in R is identical to the Python PATH where you installed ctpnet python package.

Track python location: https://stackoverflow.com/questions/2589711/find-full-path-of-the-python-interpreter
Track python in R: https://rstudio.github.io/reticulate/articles/versions.html

Zilu

@Dale007261
Copy link

Hi,I got the same error.I think you can run the code in R
repl_python()
to see the python version "reticulate" use.
you may download the package in a different python version expecially when your computer has different python version.
And I also got another error
Error in py_module_import(module, convert = convert) :
RuntimeError: The current Numpy installation ('C:\Users\Dale\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86

Detailed traceback:
File "D:\R-4.0.3\library\reticulate\python\rpytools\loader.py", line 24, in import_hook
level=level
File "C:\Users\Dale\AppData\Local\Programs\Python\Python37\lib\site-packages\ctpnet_init
.py", line 2, in
from . import predict
File "D:\R-4.0.3\library\reticulate\python\rpytools\loader.py", line 24, in _import_hook
level=level
File "C:\Users\Dale\AppData\Local\Programs\Python\Python37\lib\site-packages\ctpnet\predict.py", line 1, in
import numpy as np
File "D:\R-4.0.3\library\reticulate\python\rpytools\loader.py", line 24, in _import_hook
level=level
File "C:\Users\Dale\AppData\Local\Programs\Python\Python37\lib\site-packages\nu

The solution is to use numpy 1.19.3.
pip install numpy==1.19.3

@zhouzilu
Copy link
Owner

Thanks Dale for the update!

@zhouzilu
Copy link
Owner

Do you guys think a docker would be the solution in the future? Or do you think it will actually increase the pain since it might be harder to adapt to?

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

3 participants