trouble with Sublime REPL not finding packages - macos

What I've got:
New copy of Yosemite, homebrew installation of python 2.7, Sublime Text 2 with the following packages: LaTex tools, Package Control, Rbox, and SublimeREPL. I downloaded package feedparser with Pip.
I'm new to python (and any coding beyond R) and I'm trying to set up a good workflow with Sublime Text 2. For some reason, when I try and load feedparser in the sublime REPL python window, I get "import error, no module named feedparser".
However, I can get the packaged to load from python in the terminal.
which python in terminal I get back usr/local/bin/python which is where homebrew puts python.
I have a limited understanding of this stuff, but I'm assuming its because REPL is using the old version of python that comes with OSX.
I tried changing the environment variable in the Python.sublime-build file according to this post (first answer):
Sublime Text 2: custom PATH and PYTHONPATH
Yet, it still does not work. Maybe I did it wrong? I'm not sure.
With the number of people using Sublime text and Python I know that this must get dealt with all of the time. I've lots of posts with people suggesting many different things and I'm fairly lost.
Thanks.

For Mac OSX [Racket 6.03] [Sublime Text 3]
For those interested in RACKET (DR RACKET) Repl, and are recieving an error when launching the repl "file not found".. I found out -- after spending a couple hours trying to reconfigure files -- the solution..
Open Dr Racket.
-> Help -> Configure Command Line for Racket -> click "ok" box.
-Done.
Launch the Repl in Sublime Text.

You can add a new menu item to Tools -> SublimeREPL -> Python. First, open your Packages/User directory by selecting Sublime Text 2 -> Preferences -> Browse Packages... and opening the User directory. Create a folder in User called SublimeREPL, inside that create a config directory, and inside that create a Python directory. Finally, make a new file in Sublime with JSON syntax and the following contents:
[
{
"id": "tools",
"children":
[
{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{
"caption": "Python",
"id": "Python",
"children":
[
{
"command": "repl_open",
"caption": "Python (Homebrew)",
"id": "repl_python",
"mnemonic": "p",
"args":
{
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/usr/local/bin/python", "-i", "-u"],
"cwd": "/Users/williamrudisill/Development/python",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
]
}
]
}
]
Save this file as Packages/User/SublimeREPL/config/Python/Main.sublime-menu. Make sure you edit the "cwd" parameter to set the folder you'd like the interpreter to open in.
Now, if you open Tools -> SublimeREPL -> Python there will be an item called Python (Homebrew) that you can use to open an interpreter with /usr/local/bin/python.

Related

I can't open terminal in Visual Studio Code

The '+' button to open terminal in my visual studio code does not work.
Also, the default profile selection button does not work.
The only thing I changed was from "launch.json" to "externalConsole: false->true".
Even if I try to restore it to its original state, it remains the same. I tried reinstalling the VSCode, deleted the "setting.json" file, and recreated it. But... :(
Originally, I was using git bash as a standard, but you can see it. There is only "JavaScript Debug Terminal" left.
Please help me, friends.
My "launch.json" file
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/MinGW/bin",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb에 자동 서식 지정 사용",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 활성 파일 빌드"
}
]
I am on macOS with an issue like this as well. My terminal instantly closes when I try to open it and I have not found a good solution. The best I can do it just reinstall VScode.
I use Windows, hence commands are for Windows, but you can definitely find the alternative commands for your OS in case you happen to use an OS other than Windows.
Open your settings.json file(File -> preferences -> Settings or Ctrl+,) and look for the configuration terminal.integrated.profiles.windows (newer recommended setting). If you seeterminal.integrated.shell.windows then it is the older deprecated setting.
If you are on linux or Mac, then look for the terminal.integrated.profiles.linux or terminal.integrated.profiles.osx. If you don't find these, then perhaps you don't have any terminal profiles setup and you need to set it up.
Setting up a terminal profile is quite easy.
In your settings.json file you need to create a new setting with key terminal.integrated.profiles.windows (or terminal.integrated.profiles.linux or terminal.integrated.profiles.osx based on your system). Start typing the above key and once VSCode shows the suggestion hit Enter(Return). If you don't see any suggestion for auto-complete try hitting Ctrl+Space. Your settings will auto-populate against the above key and will look something like following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}
In addition to above you can also setup a default terminal profile. Include the below setting(here Git Bash has been configured as the default terminal profile) :
"terminal.integrated.defaultProfile.windows": "Git Bash"
You can always use the Ctrl+Space to force VScode to provide you with the possible values.
Few handy links :
To create a new profile.
To go to the command pallette(Ctrl+Shift+P on windows)

How to hide or make relative the paths that appear in the files inside the conda-meta folder?

When a build a conda environment like this
conda create --prefix env python=3.6.5
Some absolute paths appear in some json files in the conda-meta folder. How can I avoid it? I just want to use relative paths here or I just want to hide them completely. Is there a way to achieve this? Are they mandatory? See extracted_package_dir, source or package_tarball_full_path attributes:
{
"arch": "x86_64",
"build": "py36_0",
"build_number": 0,
"channel": "https://repo.anaconda.com/pkgs/main/win-64",
"constrains": [],
"depends": [
"python >=3.6,<3.7.0a0"
],
"extracted_package_dir": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0",
"features": "",
"files": [
"Lib/site-packages/certifi-2019.03.09-py3.6.egg-info",
"Lib/site-packages/certifi/__init__.py",
"Lib/site-packages/certifi/__main__.py",
"Lib/site-packages/certifi/__pycache__/__init__.cpython-36.pyc",
"Lib/site-packages/certifi/__pycache__/__main__.cpython-36.pyc",
"Lib/site-packages/certifi/__pycache__/core.cpython-36.pyc",
"Lib/site-packages/certifi/cacert.pem",
"Lib/site-packages/certifi/core.py"
],
"fn": "certifi-2019.3.9-py36_0.tar.bz2",
"license": "ISC",
"link": {
"source": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0",
"type": 1
},
"md5": "e1faa30cf88c0cd141dfe71e70a9597a",
"name": "certifi",
"package_tarball_full_path": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0.tar.bz2",
"paths_data": {
"paths": [
[...]
If I remove the whole folder the environment become useless and I cannot activate it anymore in order to install, update or remove new packages.
I want to do this to encapsulate the environment in one application and I do not want to have my original absolute paths in the computer of the final user.
My Use Case
I am developing an electron app that uses a tornado server (that uses python)
Currently I am using electron-builder to add the environment to the installer and works pretty well, but one drawback is the conda-meta folder I commented above. What I do now is to remove it manually when I want to make an installer.
That will probably break conda. It's not written to treat those as relative paths. If you told us more about your use case, maybe we could help. Are you trying to redistribute an installed environment? Have you see the "constructor" or "conda-pack" projects?
Finally the best solution I found was to ignore the folder when creating the final installer with electron-builder.
So I have applied the directive extraResources to add the conda environment except the folder conda-meta. And I have added the filter "!conda-meta${/*}", the meaning is explained here
Remember that !doNotCopyMe/**/* would match the files in the doNotCopyMe directory, but not the directory itself, so the empty directory would be created. Solution — use macro ${/*}, e.g. !doNotCopyMe${/*}.
The result in the package.json file:
"extraResources": [
{
"from": "../env",
"to": "env",
"filter": [
"**/*",
"!*.pyc",
"!conda-meta${/*}"
]
}
],

How to compile Sass to CSS in Sublime Text 3 automatically?

For example, there is package for less LessToCss. As for Sass(or SCSS) I don't know what i should do. Ruby and sublime package Sass are installed.
You have to alter the PATH variable at the end of PATH string in the Environment Variables: Desktop - Properties - Environment Variables. It for win vista/7 users. Detail for 2000/XP here Sass compiler not working in sublime text 3
One way is to download a SASS build compiler from here: SASS Compiler
This is automatic Sublime package that simply builds your file at the place.
However since they released the new version, there seem to be multiple settings on this package - you could try to mess with that a bit and see what it can do nowdays.
Second way is to write your own Build command in Sublime. You do this by going to "Tools>Build System>New Build System..."
{
"cmd": ["sass", "--update", "$file:${project_path}/Project/Web/css/${file_base_name}.css", "--stop-on-error", "--style", "compressed", "--no-cache", "--sourcemap=none"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
Explanation: I use a folder structure as the following: Project/Web/CSS - If you have the Sublime Project FILE at the same level as Project FOLDER, then this will automatically build your Sass file (placed ANYWHERE in the project file) in your Web/CSS folder. Of course you can change this as you see fitting.
here is 100% solution, as i also using. Actually i am using in mac so, i am not sure about windows because i wouldn't try yet in windows but i think it will works in window's too.
so here is the build;
copy this from starting brackets and paste it into build and then save with any name like (Build to CSS),"
{
"cmd": ["sass", "--update", "$file:${file_path}/../css/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"osx":
{
"path": "/user/local/bin:$PATH"
},
"windows":
{
"shell": true
}
}
If it's working then please comment.
Thanks

Could someone help me configure MinGW in SublimeText 3? (Newbie)

I downloaded MinGW following the first link here https://isocpp.org/get-started and now I need to configure it in SubimeText 3. I know I should go to Tools > Build System > New Build System... But what should I specify there?
I use Win7x64. And MinGW is in C:\MinGW
The complete reference for build systems is here. The first thing you need to do is make sure that the C:\MinGW\bin directory is in your PATH, then restart Sublime so the change gets picked up.
Once you've done that, create a new build system with the following contents:
{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"variants":
[
{
"name": "Run",
"cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
"shell": true
}
]
}
and save it as Packages/User/C.sublime-build where the Packages folder is the one opened by selecting Preferences -> Browse Packages....
You can now choose this build system by selecting Tools -> Build System -> C. Once you are ready to compile, save your source file, then hit CtrlB to build. To run the program, hit CtrlShiftB and a cmd window will open up to run the resulting .exe file, then stay open until you close it (so you can see any output produced by the program).
You can try to use the C++ build system that comes with Sublime, but some users have run into issues with it in the past, especially on Windows, so this custom one may suit your needs better.
Good luck!

Disable Sublime Text 3 plugin from a custom menu

In Sublime Text 3, I'm using the WordCount plugin to know how long a file is, in terms of words.
However, this plugin slows down the editor when a huge text file is open. It's a file I use quite often, so this proves annoying. (The file is close to 6MB/1 million words and used on a recent MacBookPro.)
As such, I want to be able to disable and re-enable the WordCount plugin quickly and easily. I know how to do disable a plugin through Palette commands but I'm not happy with this solution.
Instead, I'd like to use a custom menu. I can create the custom menu itself (with a file named Main.sublime-menu located in /Users/*myusername*/Library/Application Support/Sublime Text 3/Packages/User/Main.sublime-menu) :
[
{
"caption": "Custom",
"id": "custom",
"children":
[
{ "command": "*somecommandhere*", "args": {}, "caption": "Toggle WordCount plugin", "checkbox": true }
]
}
]
However, I don't know which command to use to disable/re-enable a plugin. I assume this would be the same command from the console and inside of a menu file.
The following Main.sublime-menu will work:
[
{
"caption": "Custom",
"id": "custom",
"children": [
{
"caption": "Disable Package",
"id": "disable_package",
"command": "disable_package"
}
]
}
]
When selected, it opens a dropdown menu with all of the currently-active packages listed, and you can use fuzzy matching to quickly select the package you want to disable. Unfortunately, there is no way to specify which package you want to disable, as DisablePackageCommand doesn't take any arguments.
I am under exactly the same situation as you. Same big default file, same MBP, same WordCount plugin. And here is my solution.
To disable packages
Press super + , to bring up Preferences.sublime-settings, which can also be allocated at:
OSX
~Library/Application Support/Sublime Text 3/Packages/User
Windows
C:\Users\USERNAME\AppData\Roaming\Sublime Text 3\Packages\User
Linux
~/.config/sublime-text-3/Packages/User
Because the package Vintage is disabled by default, you should find these lines in your Preferences.sublime-settings.
"ignored_packages":
[
"Vintage"
],
Add "WordCount", (include the comma) before the last package(i.e. "Vintage") inside "ignored_packages".
"ignored_packages":
[
"WordCount",
"Vintage"
],
Save the file. That is it! The WordCount plugin has been disabled.
To enable packages
press super + , to bring up Preferences.sublime-settings, use supre + / to comment out the package. Like this:
"ignored_packages":
[
// "WordCount",
"Vintage"
],
Save the file. That is it! The WordCount plugin has been disabled.
To toggle packages like a pro (conclusion)
super + , to bring up preferences.
super + / to enable or disable packages.
super + s to profit.
No mouse, no plugin needed, no need to restart ST.
It is very simple and fast. I always use this method to quickly enable and disable packages in Sublime Text. Hope it help :)

Resources