Open vlurgio opened 6 years ago
Is there a way to recreate this issue? I can't seem to replicate it
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
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
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
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!
@LukeyQ1 this doesn't only happen when opening with command line, it always happens.
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
@pavanagrawal123 That worked for me thanks a ton made this worth using!
@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.
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.
can reproduce
Just checking. Encountering the same issue and wondering the status of this.
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?