"Run File in Python Console" looking for wrong directory

Viewed 155

Current situation:

  1. I ssh'ed into my school's cluster.

  2. Activated a virtual env.

  3. Trying to run DataPhenograph.py

  4. File system:

rotarod_ML
    |---- featureImportance
    |       |---- tsne
    |               |---- dataPhenography.py
    |
    |---- rotarod_ML
    
import os
os.getcwd()
'/alder/home/myid'
os.chdir('rotarod_ML')
os.getcwd()
'/alder/home/myid/rotarod_ML'
os.listdir()
['.ipynb_checkpoints', 'data_all', 'utils', 'README.md', 'dataAnalysis', 'main.py', 'dataPrep', '.idea', 'visualization', 'rotarod_ML', '.git', 'output', '__init__.py', 'featureImportance', 'MachineLearningAnalysis']
os.chdir('featureImportance')
os.chdir('tsne')
os.listdir()
['b263fd3a6d9311eb80a200110a6c2a51_graph.weights', 'untitled.txt', 'ORIGINAL.py', '9b5fe4aa6d9311eb970000110a6c2a51_graph.bin', '.ipynb_checkpoints', 'rigid_transform_3D.py', '__pycache__', '9b5fe4aa6d9311eb970000110a6c2a51.tree', 'aaa.ipynb', 'syn_2d_tsne.png', 'WTday3.png', 'b263fd3a6d9311eb80a200110a6c2a51.tree', '.idea', 'b263fd3a6d9311eb80a200110a6c2a51.bin', 'DataPhenograph.py', '9b5fe4aa6d9311eb970000110a6c2a51_graph.weights', '9b5fe4aa6d9311eb970000110a6c2a51.bin', 'tsneOriginalModified-pages-deleted.pdf', 'DataPhenograph-oneBlock.ipynb', 'b263fd3a6d9311eb80a200110a6c2a51_graph.bin']

Problem:

Now, when I click on the code and press Run file in python console, it gives me the following error:

runfile('/alder/home/myid/featureImportance/tsne/DataPhenograph.py', wdir='/alder/home/myid/featureImportance/tsne')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/alder/home/myid/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 193, in runfile
    os.chdir(wdir)
FileNotFoundError: [Errno 2] No such file or directory: '/alder/home/myid/featureImportance/tsne'

For some reason, wdir is not correct?! So I changed it to

runfile('/alder/home/myid/featureImportance/tsne/DataPhenograph.py', wdir='/alder/home/myid/rotarod_ML/featureImportance/tsne')

Then, I get

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/alder/home/myid/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/alder/home/myid/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/alder/home/myid/rotarod_ML/featureImportance/tsne/DataPhenograph.py", line 4, in <module>
    from utils.getDirAbsPath import dataAbsPath
ModuleNotFoundError: No module named 'utils'

Note that here is the first few lines of code in dataPhenography.py:

print('hi##############')
from sklearn.manifold import TSNE
from scipy.cluster.hierarchy import dendrogram
from pytransform3d.rotations import *
from utils.getDirAbsPath import dataAbsPath

import sys
import os

sys.path.append("..")
import cv2
from os import listdir
from os.path import isfile, join
import matplotlib

import matplotlib.pyplot as plt
import pandas as pd
import phenograph
import io
print(1)

There used to be import utils but there aren't anymore. When I debug, it does highlight the rows being executed on the right file. Can someone please help me with this problem? Thank you!

0 Answers
Related