Closed Kristinita closed 7 years ago
Hmm... does Exalt work for you despite these stack traces?
You mention that you have Python 3.6.0 and lxml 3.7.3 installed. I wonder whether Sublime Text is trying to use the lxml you have installed instead of its dependency...?
I can't reproduce either error, but I'll try to look into it a bit more when I get the chance.
@eerohele , please, to see my Stack Overflow question, 6.2 item about your lxml
dependency. Possibly, question relate with this issue.
Thanks.
I think @eerohele might be on to something here:
You mention that you have Python 3.6.0 and lxml 3.7.3 installed. I wonder whether Sublime Text is trying to use the lxml you have installed instead of its dependency...?
what is the output of import sys; sys.path
in the ST console @Kristinita ?
on my computer it is
['C:\\Program Files\\Sublime Text 3', 'C:\\Program Files\\Sublime Text 3/python3.3.zip', 'C:\\Users\\Keith\\AppData\\Roaming\\Sublime Text 3\\Packages', 'C:\\Users\\Keith\\AppData\\Roaming\\SUBLIM~1\\Packages\\lxml\\ST3_WI~2']
if it contains anything outside of the ST installation folder and Packages folder, then most likely your system-wide packages are being picked up, which won't work well with ST unless the Python version on your system is the same as ST's - which it isn't. So you will need to remove these from the path, so that ST won't pick them up, and instead correctly use the ST dependency package.
@keith-hall ,
Thanks for the answer! Now my plugin works!
My plugin. I don't need to remove global lxml.
import re
import sys
import urllib
from w3lib.url import safe_url_string
import sublime_plugin
sys.path.append('C:\\Python36\\Lib\\site-packages')
from bs4 import BeautifulSoup # noqa
class KristinitaLuckyLinkCommand(sublime_plugin.TextCommand):
def run(self, edit):
# Get selection text
print('KristinitaLuckyLink called')
select = self.view.sel()
selection_region = select[0]
selection_text = self.view.substr(selection_region)
print(selection_text)
# ASCII link for solved encoding problems —
# http://stackoverflow.com/a/40654295/5951529
ascii_link = safe_url_string(
u'http://duckduckgo.com/html/?q=' + (selection_text),
encoding="UTF-8")
print(ascii_link)
# SERP DuckDuckGo
serp = urllib.request.urlopen(ascii_link)
# Reading SERP
read_serp = serp.read()
# BeautifulSoup — http://stackoverflow.com/a/11923803/5951529
parsed = BeautifulSoup(read_serp, "lxml")
# Parsed first link
first_link = parsed.findAll(
'div', {'class': re.compile('links_main*')})[0].a['href']
# Remove DuckDuckGo specific characters —
# http://stackoverflow.com/a/3942100/5951529
remove_duckduckgo_symbols = first_link.replace("/l/?kh=-1&uddg=", "")
# Final link — http://stackoverflow.com/a/32451970/5951529
final_link = (urllib.parse.unquote(remove_duckduckgo_symbols))
markdown_link = '[' + selection_text + ']' + \
'(' + final_link + ')'
print(markdown_link)
# Replace selected text to Markdown link
self.view.replace(
edit, selection_region, markdown_link)
Output:
>>> import sys; sys.path
['D:\\Sublime Text 3 x64\\Data\\Packages\\FileHeader', 'D:\\Sublime Text 3 x64\\Data\\Packages\\WakaTime\\packages\\wakatime\\packages', 'D:\\Sublime Text 3 x64\\Data\\Packages\\WakaTime\\packages\\wakatime\\packages', 'D:\\Sublime Text 3 x64\\Data\\Packages\\WakaTime\\packages', 'D:\\Sublime Text 3 x64\\Data\\Packages\\WakaTime\\packages', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Python PEP8 Autoformat\\libs\\py33', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Python PEP8 Autoformat\\libs', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Mediawiker\\lib\\pyaes.zip', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Mediawiker\\lib\\pbkdf2.zip', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Mediawiker\\lib\\keyring.zip', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Travis YML Lint\\lib', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github\\lib', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github\\lib', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github', 'D:\\Sublime Text 3 x64\\Data\\Packages\\sublime-github', 'FileHeader', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Browser Refresh\\win', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Browser Refresh', 'D:\\Sublime Text 3 x64', 'D:\\Sublime Text 3 x64/python3.3.zip', 'D:\\Sublime Text 3 x64\\Data\\Packages', 'D:\\SUDCA3~1\\Data\\Packages\\pygments\\all', 'D:\\SUDCA3~1\\Data\\Packages\\lxml\\ST3_WI~2', 'D:\\SUDCA3~1\\Data\\Packages\\PATHTO~2\\all', 'D:\\SUDCA3~1\\Data\\Packages\\coverage\\ST3_WI~2', 'D:\\SUDCA3~1\\Data\\Packages\\PACKAG~1\\all', 'D:\\SUDCA3~1\\Data\\Packages\\watchdog\\all', 'D:\\SUDCA3~1\\Data\\Packages\\backrefs\\st3', 'D:\\SUDCA3~1\\Data\\Packages\\dateutil\\all', 'D:\\SUDCA3~1\\Data\\Packages\\gntp\\all', 'D:\\SUDCA3~1\\Data\\Packages\\MARKUP~1\\all', 'D:\\SUDCA3~1\\Data\\Packages\\oauthlib\\all', 'D:\\SUDCA3~1\\Data\\Packages\\PY2BF6~1\\st3', 'D:\\SUDCA3~1\\Data\\Packages\\python-pywin32\\st3_windows_x64', 'D:\\SUDCA3~1\\Data\\Packages\\python-pywin32\\st3_windows_x64\\win32', 'D:\\SUDCA3~1\\Data\\Packages\\python-pywin32\\st3_windows_x64\\win32\\lib', 'D:\\SUDCA3~1\\Data\\Packages\\python-pywin32\\st3_windows_x64\\win32comext', 'D:\\SUDCA3~1\\Data\\Packages\\pytz\\all', 'D:\\SUDCA3~1\\Data\\Packages\\pyyaml\\st3', 'D:\\SUDCA3~1\\Data\\Packages\\regex\\ST3_WI~2', 'D:\\SUDCA3~1\\Data\\Packages\\requests\\all', 'D:\\SUDCA3~1\\Data\\Packages\\PY8724~1\\all', 'D:\\SUDCA3~1\\Data\\Packages\\REQUES~1\\all', 'D:\\SUDCA3~1\\Data\\Packages\\mdpopups\\st3', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Cloudup\\requests', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Codec\\idna', 'D:\\Sublime Text 3 x64\\Data\\Packages\\EditorConfig', 'D:\\Sublime Text 3 x64\\Data\\Packages\\EditorConfig', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Emmet.sublime-package', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Emmet.sublime-package\\emmet_completions', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Emmet.sublime-package\\emmet', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\IndentX.sublime-package', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Javascript Beautify.sublime-package\\libs', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Javascript Beautify.sublime-package\\libs\\js-beautify\\python', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Pywin32\\lib\\x64\\win32', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Pywin32\\lib\\x64\\win32\\lib', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Pywin32\\lib\\x64', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Pywin32\\lib\\x64\\win32comext', 'D:\\Sublime Text 3 x64\\Data\\Packages\\coverage\\st3_windows_x64', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\Web Inspector.sublime-package', 'D:\\Sublime Text 3 x64\\Data\\Packages\\CodeFormatter\\codeformatter\\lib', 'D:\\Sublime Text 3 x64\\Data\\Packages\\CodeFormatter\\codeformatter\\lib\\htmlbeautifier', 'C:\\Python36\\Lib\\site-packages', 'D:\\Sublime Text 3 x64\\Data\\Packages\\Highlight/HighlightLib', 'C:\\Python36', 'C:\\Python36\\Lib\\site-packages', 'C:\\Python36', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs', 'C:\\Python36\\lib', 'C:\\Users\\SashaChernykh\\AppData\\Roaming\\Python\\Python36\\site-packages', 'C:\\Python36\\lib\\site-packages', 'C:\\Python36\\lib\\site-packages\\xgoogle-1.3-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pyment-0.3.2.dev0-py3.6.egg', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\PyV8', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\PyV8\\win64-p3', 'D:\\Sublime Text 3 x64\\Data\\Installed Packages\\PyV8\\pyv8-win64-p3', 'C:\\Python36\\Lib\\site-packages', 'C:\\Python36\\Lib\\site-packages']
I remove all C:\\Python36
paths → plugin successful works for me.
sys.path
?@keith-hall, please, post your answer to Stack Overflow. I give bounty for you — small award for you helps.
Thanks.
Now after paths removing, I don't reproduce this issue.
Thanks.
@keith-hall , bounty end today, tomorrow I can't give you bounty.
Thanks.
1. Summary
I get stack trace in console, when I run Sublime Text.
2. Expected behavior
No stack trace in console.
3. Actual behavior
Stack trace 1:
Stack trace 2:
4. Steps to reproduce
I reproduce the problem in a version of Sublime Text without plugins and user settings.
I install Exalt via Package Control → I get stack trace 1. I restart Sublime Text → I get stack trace 2.
5. Environment
Operating system and version: Windows 10 Enterprise LTSB 64-bit EN Sublime Text: Build 3126 Python 3.6.0 lxml: 3.7.3
Thanks.