How to setup SublimeREPL to load current working directory - sublimetext3

I have installed ipython jupyter console for sublimeREPL using the link https://gist.github.com/MattDMo/6cb1dfbe8a124e1ca5af
However, I face a problem, when I start the "Jupyter Console", it doesn't load the current directory in which I am working.
For Instance, I am working on a file "text.py in directory "/home/sam/desktop/programs/" and I run a manual import "import text" in the sublimeREPL (jupyter console), I get a module not found error
ImportError Traceback (most recent call last)
<ipython-input-3-0660e90ee9d4> in <module>()
----> 1 import text
ImportError: No module named text
I refered to the link Set working directory to location of active script in SublimeREPL
and checked the directory of cwd using os.getcwd()
The directory that I see is /opt/sublimetext
I even tried changing the "cwd" from "cwd": "$file_path", to the current path,"cwd": "/home/sam/desktop/programs/" in the "Main.sublime-menu" file
I was wondering if there is a way that I could register the directory manually or even better if sublimeREPL would automatically pick the directory, since I'll be importing files from different locations.
Thanks.

Related

Import script in sub directory not working... Blender Add-On

I have a folder structure like this:
C:
|_Blueprint
│ main.py
│
└───toolbox
blueprint_tools.py
When I run this code in Blender's scripting text page:
from toolbox.blueprint_tools import dimension, array, modify
I get an error in the console
Traceback (most recent call last):
File "\main.py", line 20, in <module>
ModuleNotFoundError: No module named 'toolbox'
Error: Python script failed, check the message in the system console
I swear, when I run this code (on other projects) outside of Blender this structure and code runs fine. But I get an error when running this script in Blender for testing out my Add-On.
If I compile the Blueprint folder into a .zip and install it everything works fine.... ??
I'm lost, could anyone please help me.
If I run the code like this: (added a . before toolbox for CWD)
from .toolbox.blueprint_tools import dimension, array, modify
Traceback (most recent call last):
File "\main.py", line 20, in <module>
ImportError: attempted relative import with no known parent package
Error: Python script failed, check the message in the system console
Both your error traces write File \main.py ... which means that Blender considers your main.py file to be in the root folder, knowing nothing about its real location in the file system hierarchy.
When you installed your structure as a zip file, you provided all necessary info to Blender.
Addendum:
Temporarily, during developing / debugging your add-on, you may add the full path (for finding your toolbox.blueprint_tools module) to the sys.path variable.
There are 2 possibilities how to do it:
Insert into your main.py file these commands (use the path to your parent folder of your toolbox folder, of course):
import sys
sys.path += [r"C:\Users\Davi\Documents\Python\PARENT_of_toolbox"]
before your statement
from toolbox.blueprint_tools import dimension, array, modify
command, or
Insert into your main.py file these commands (use the path to your toolbox folder, of course):
import sys
sys.path += [r"C:\Users\Davi\Documents\Python\PARENT_of_toolbox\toolbox"]
before your modified statement
from blueprint_tools import dimension, array, modify

ModuleNotFoundError: No module named '_pydevd_bundle'

Out of the blue I got the error listed below.
I am using Eclipse IDE and I have Python 2.7 and 3.6 installed (both WinPython)
I don't know when this started because I have worked for a while in 2.7. I just tried some code which I am writing in Jupyter and it is not working and I wanted to debug it easier in Eclipse. When I press the debug button I get the below
Traceback (most recent call last):
File "C:\Utils\PortableApps\PortableApps\Eclipse 4.6\plugins\org.python.pydev.core_7.0.3.201811082356\pysrc\pydevd.py", line 20, in <module>
from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
ModuleNotFoundError: No module named '_pydevd_bundle'
It's absolutely due to that your files contain a dir named code! The name has conflicted with the system package. Just modify the dir name code to any name else. It should work well!

Python unable to understand directory structure after moving the project to a cloud

Recently I bought a droplet in digital ocean to put my project live.It works just fine in my local computer and doesn't have any problem with the directory structure.However once I put this on a server, Python throws an error.Below is my project structure in my local computer.
Now when I move it to a server, this is my project structure
Now If I run a test file just to test the imports
cd integretation
ls
__init__.py __pycache__ request_constructor.py test.py
test.py
from format_data.output_filter import output_filter
print("Yes")
Now I run the file
python3 test.py
I get an error
Traceback (most recent call last):
File "test.py", line 1, in <module>
from format_data.output_filter import output_filter
ImportError: No module named 'format_data'
Why is that happening though the same import structure works in my local computer? I even tried to change the import to something like this
from service_rest.format_data.output_filter import output_filter
But this doesn't help either.What is going wrong?
Note: I have removed the topmost level directory ServiceHandler when transferring the files to the server.But adding it back doesn't help either.

How to run .bat files on windows 2016 server on EC2, after python has been configured?

I need to kick off a python script on 2016 windows server EC2 instance on AWS.
When I set the task up in 'task scheduler' the script does not run. I have tried setting up a batch file with the following code:
#echo off
python C:\Users\Administrator\Desktop\script.py %*
pause
I get the following error when I double click the batch file:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\script.py", line 8, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Press any key to continue . . .
I am running python 3.6 on anaconda in the windows environment in which my script runs fine. I have also downloaded python 3.6 from the python website and confirmed the path variables exist. Also pandas works in anaconda.
batch filename:
test.bat
Not sure why my libraries not being read in?
The solution was too restart anaconda, after adjusting the path variables.

Error with import script in colaboratory

When I try to import a script that is in the same folder as the colaboratory
then I get an error:
ImportErrorTraceback (most recent call last)
<ipython-input-8-e7a4315427c8> in <module>()
----> 1 import translate
ImportError: No module named translate
The path and location of the file checked!!!
Colab doesn't automatically load any files from your Google Drive folder; you'll need to copy the files locally (eg with something like https://colab.research.google.com/notebooks/io.ipynb#scrollTo=P3KX0Sm0E2sF and then saving to a file).

Resources