siheming / mspypeline

Package to analyze Mass Spec Data
MIT License
11 stars 11 forks source link

Issues getting started #36

Closed cstgermain4 closed 1 year ago

cstgermain4 commented 1 year ago

So I am trying to use MSPypeline through Jupyter Notebook and keep getting errors.

I ran:

!pip install mspypeline

from mspypeline import MSDataFile
from mspypeline.plotting import plot_ion_mobility_spectrum

And received the following warning: UwerWarning: R_HOME environment variable is not set and location could not be inferred

So then I went into my systems enivronments and fixed it to contain a R_HOME environment with the correct installation directory. But now when I run the last bit, I get the following error:

ImportError                               Traceback (most recent call last)
Cell In[9], line 1
----> 1 from mspypeline import MSDataFile
      2 from mspypeline.plotting import plot_ion_mobility_spectrum

ImportError: cannot import name 'MSDataFile' from 'mspypeline' (C:\Users\STGECC\AppData\Local\anaconda3\lib\site-packages\mspypeline\__init__.py)

I tried reinstalling and updating MSPypeline multiple times and it doesn't seem to be helping. Any help would be great.

siheming commented 1 year ago

Hi @cstgermain4 , so the import worked intially, after you ran the pip install command? What did you do to fix the warning exactly? Could you maybe also have manipulated other environment variables, which point to your python installation? Did the import work again after you reinstalled but not set the environment variable?

In general I would recommend to not install anything from within a jupyter notebook but testing it plain on the console. So depending on what you use create a new py venv or conda venv, activate it in the console, install mspypeline, start the python interpreter on the console and test the imports you listed. Also, since you plan to work from within a notebook you cold set the venv variable in the notebook by import os; os.environ["R_HOME"] = os.path.join("path", "to", "your", "R")

cstgermain4 commented 1 year ago

So I've tried running it both in python and in a conda environment. When I try in the python, I am unable to create a local environemnt:

image

And in Anaconda it will cycle through the following two things until it gives up (collecting package metadata followed by solving environment: failed) image

I reinstalled my python and everything to make sure it was all up to date.

When I received the warning:

UwerWarning: R_HOME environment variable is not set and location could not be inferred

I went into my settings-->edit environment variables-->New, then added R_HOME with a file directory to my Rprogram. Then I restarted my jupyter kernal and reran the installation.

I also just ran your suggestion about the import, and maybe I am doing this in the wrong order. I am pretty new to coding, so if I mess something up please feel free to let me know. So in the notebook I ran the following:

import os

os.environ["R_HOME"] = os.path.join(r"C:\Users\STGECC\AppData\Local\Programs\R\R-4.3.1\bin\x64")

python3 -m venv mspypeline

output:
  Cell In[5], line 1
    python3 -m venv mspypeline
               ^
SyntaxError: invalid syntax

I'm open to using a python or anaconda environment instead of Jupyter, I just felt like I got further in the jupyter notebook.

siheming commented 1 year ago

There are multiple issues with different things you wrote about, but they might not be really relevant :D I am not really sure where you got the name MSDataFile from, maybe you were looking at another library? examples of how to analyse your data in a custom fashion can be found here: https://mspypeline.readthedocs.io/en/latest/examples.html

siheming commented 1 year ago

it might be simpler to start with the gui first to analyse your data, which is explained here https://mspypeline.readthedocs.io/en/latest/get_started.html#usage-with-gui

siheming commented 1 year ago

I will close this issue for now, hope you had success