calico / scnym

Semi-supervised adversarial neural networks for classification of single cell transcriptomics data
https://scnym.research.calicolabs.com
Apache License 2.0
74 stars 11 forks source link

Problems with scnym installation using conda #5

Closed timlai4 closed 4 years ago

timlai4 commented 4 years ago

I attended the scNym talk at ISMB and I'm interested in trying out scNym! However, I am having some issues setting up a local environment using conda to run scNym. I will detail the issues chronologically as well as my workarounds.

Issue 1: The README instructs to create an empty conda environment, with no specification for python distributions, and then running pip. Even if you activate into the environment, because there is no Python and hence no pip, it will either fail or worse, if you have Python installed natively on the machine, the pip call will default to that.

Solution: Instead of running conda create -n scnym_env, add in something like conda create -n scnym_env -c conda-forge python.

Issue 2: After doing the above and running pip install scnym, scNym (command-line) does not work.

$ scnym --help
Traceback (most recent call last):
  File "/home/timlai/anaconda3/envs/scnym_env/bin/scnym", line 8, in <module>
    sys.exit(main())
  File "/home/timlai/anaconda3/envs/scnym_env/lib/python3.8/site-packages/scnym/main.py", line 1316, in main
    import yaml
ModuleNotFoundError: No module named 'yaml'

Solution: https://stackoverflow.com/a/56992964/13906501 takes care of this. Perhaps update the requirements to include this?

Issue 3: Although numbered 3, this seems to be independent of 2. Specifically, attempting this immediately after 1 or after the fix mentioned in 2 results in the same error.

Testing the API:

$ echo "from scnym.api import scnym_api" > test.py
$ python test.py
Traceback (most recent call last):
  File "/home/timlai/scRNA/PAGA/scNYM/scnym.py", line 12, in <module>
    from scnym.api import scnym_api
ModuleNotFoundError: No module named 'scnym.api'; 'scnym' is not a package

I do not have a solution for this and would appreciate some advice.

jacobkimmel commented 4 years ago

Hi Tim,

Thanks for your interest and detailed bug report.

Solution: Instead of running conda create -n scnym_env, add in something like conda create -n scnym_env -c conda-forge python.

Apologies for the oversight on my part, we've updated the README.

Solution: https://stackoverflow.com/a/56992964/13906501 takes care of this. Perhaps update the requirements to include this?

Sorry about that, I've added PyYAML to requirements.txt so this shouldn't happen in the future.

Issue 3: Although numbered 3, this seems to be independent of 2. Specifically, attempting this immediately after 1 or after the fix mentioned in 2 results in the same error.

This traceback looks like a namespace collision with a file you created. What's scnym.py? That's not a module in our package, but it appears to be on your PYTHON_PATH.

If that file appears earlier in the path than the scnym package, it will be imported preferentially. Python is then searching the contents of this file for .api and failing because it's not present.

I created a fresh conda environment with following commands and both the CLI and Python API work.

conda create -n scnym_issue5 -c conda-forge python
conda activate scnym_issue5
which python # returns a conda specific path
pip install scnym PyYAML # adding PyYAML to req. with PR for this issue
scnym -h # returns successfully
python -c "from scnym.api import scnym_api" # runs successfully

To fix this issue, I'd double check your activate PYTHON_PATH before from scnym.api import scnym_api. You can do this by with import sys and print(sys.path). My bet is that your scnym.py file is in a directory listed there.

Hopefully that solves your issue. Thanks again for the bug report, and let me know if you have more questions!

timlai4 commented 4 years ago

Good catch, thanks!