Some time ago I asked the question:
RunUMAP in Seurat not working: module 'umap' has no attribute 'UMAP'
It was solved by following the answer in it, however, it is still not working when I run a python script from terminal, giving the same error:
python python/umap.py -path
"/Users/nikitavlasenko/python_scripts/output/" -data
"/Users/nikitavlasenko/python_scripts/data_files/WT_SCID_CCA.csv"
Traceback (most recent call last): File "python/umap.py", line 26, in result = umap.UMAP().fit_transform(data.T) AttributeError: module 'umap' has no attribute 'UMAP'
From inside spyder
the same script runs perfectly, but somehow when running it from the terminal it is not successful. I am new to python, so maybe I am not pointing correctly to umap
library? Maybe it should be imported in a different way? Here is the whole script:
import umap
import numpy as np
def getopts(argv):
opts = {} # Empty dictionary to store key-value pairs.
while argv: # While there are arguments left to parse...
if argv[0][0] == '-': # Found a "-name value" pair.
opts[argv[0]] = argv[1] # Add key and value to the dictionary.
argv = argv[1:]
return opts
if __name__ == '__main__':
from sys import argv
myargs = getopts(argv)
print(myargs)
path_to_save = myargs['-path']
path_to_data = myargs['-data']
data = np.loadtxt(open(path_to_data, "rb"), delimiter=",", skiprows=1)
result = umap.UMAP().fit_transform(data.T)
np.savetxt(path_to_save + "/umap.csv", result, delimiter=",")
Python version that is used by spyder
and in the terminal seems to be the same: 3.6
. I am using Mac OSX
.
print(umap.__file__)
early on. It's likely that you're getting a different copy of umap. $\endgroup$