neuron-team / vscode-ipe

Interactive programming experience for data scientists: Visual Studio Code extension
MIT License
353 stars 27 forks source link

Does not run kernel from current path #167

Open vlurgio opened 6 years ago

vlurgio commented 6 years ago

The kernel doesn't seem to be opening in the folder vscode is currently in and due to this i'm not able to import any of my files in the same directory. Anyway around this?

LukeyQ1 commented 6 years ago

Is there a way to recreate this issue? I can't seem to replicate it

vlurgio commented 6 years ago

Try to make your own module in the same directory and do something like,

from myfile import my_function

and it gives me no module named myfile the namespace doesn't seem to be coming from the folder you're in even if you manually add the folder to pythonpath

vlurgio commented 6 years ago

As a demonstration I'm currently in a folder in VSCode as in I did

code . 

in the folder. If I run

import sys
sys.path

in neuron I get:

['',
'/',
'/Users/vlurgio/VSCodeProjects/python',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
'/Users/vlurgio/Library/Python/3.6/lib/python/site-packages',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lsh-0.3.0-py3.6-macosx-10.6-intel.egg',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/extensions',
'/Users/vlurgio/.ipython']

You can see the second item there is "/" meaning it's running neuron in my root directory instead of the directory I opened VSCode in, therefore i can't import any functions from files not in a module on my path.

If I do the same thing from ipython run in the same directory I get:

['',
 '/Library/Frameworks/Python.framework/Versions/3.6/bin',
 '/Users/vlurgio/VSCodeProjects/python/anomaly_detection/python',
 '/Users/vlurgio/VSCodeProjects/python',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
 '/Users/vlurgio/Library/Python/3.6/lib/python/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lsh-0.3.0-py3.6-macosx-10.6-intel.egg',
 '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/extensions',
 '/Users/vlurgio/.ipython']

Where the third option there is the folder I'm currently in

pavanagrawal123 commented 6 years ago

Hey @vlurgio I can reprod this issue, and I am working on a fix.

I filed https://github.com/jupyterlab/jupyterlab/issues/5522 to help sort this bug out.

Unfortunately, it doesn't look like there is too much activity regarding PR merging, so this might have to be fixed in the package I'm forking out of here. https://github.com/pavanagrawal123/vscode-ipe

pavanagrawal123 commented 6 years ago

Hey @vlurgio for the time being, I have added a fix to my version: https://github.com/pavanagrawal123/VSNotebooks, unfortuneatly it's not a great fix, but it works :)

The link to the extension is in the readme!

pavanagrawal123 commented 6 years ago

@LukeyQ1 this doesn't only happen when opening with command line, it always happens.

vlurgio commented 6 years ago

Oh yeah sorry i did try it opening things in the app too and yeah it's not just a command line thing. The shell always runs from the root folder

vlurgio commented 6 years ago

@pavanagrawal123 That worked for me thanks a ton made this worth using!

pavanagrawal123 commented 6 years ago

@vlurgio Good to hear! I'll be adding in tons of new features, let me know if you run into any bugs by filing an issue here: https://github.com/pavanagrawal123/VSNotebooks, I'll be happy to help and solve any issues.

vlurgio commented 6 years ago

Only other thing I noticed is sys.path only changed if vs code is closed in between opening it with a terminal. Doesn't work with code -r but yeah other than that it solves a ton of problems.

deserat commented 6 years ago

can reproduce

changeling commented 5 years ago

Just checking. Encountering the same issue and wondering the status of this.