I must be missing something simple here. I'm trying to run a command in Sublime Text 2. Any command. My understanding is that I should be abke to open the console, type a command, hit enter, and it will execute. However, for any command I try I get the following response:
>>> selectAll
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'selectAll' is not defined
Also, if I try running view.run_command('selectAll'), I don't get an error message, nor does the command appear to execute.
What am I doing wrong?
This should work...
view.run_command("select_all")
You can take a look inside Packages/Default in order to find out many other commands.
Related
I tried to run a function with octave-GUI.
I first write a function in 'testFunc.rtf'(in WordPad).
function y = testFunc(x)
y = x^2 + x^3
The path to this file is 'C:\Users\username\Desktop'.
Then on octave-GUI, I wrote such code:
cd 'C:\C:\Users\username\Desktop';
testFunc(4);
The result of this was just an error below:
error: 'testFunc' undefined near line 1, column 1
How can I solve this problem?
Just in case someone like me finds this page, and the above suggestion still doesn't help, some advice. This is running on a Win10 machine:
The error text itself means nothing. It's very poor. It just means "oops, something went wrong and we can't tell you why".
In my case, the file existed, and had the correct name. And was in the "current directory". Using the octave command "what" showed it was there.
But try as I might, it always gave me the error above. I tried so many things I saw suggested in other search results, like making sure the function def was at the first line of the file, etc. Even tried changing DOS -> unix line endings (cr/lf to lf). Nothing.
Then it occurred to me that I was trying to run off of a "samba share" from a linux drive. Even though it had read/write/execute privileges, it just would not actually run.
Moved the file(s) to a windows drive and it started working!
Sheesh. Good luck, all.
Avner
I've been working on writing some mkdocs documentation which includes mermaid diagrams that I'd like to keep in the markdown files instead of turning into images and embedding them
I came across this great solution here: https://github.com/squidfunk/mkdocs-material/issues/693#issuecomment-411885426
Which uses the super-fences feature of the pymdown-extensions plugin to create a custom code block which renders the mermaid diagrams inside the code block.
It works in mkdocs running locally, but when I submit the configuration file to readthedocs it fails the yaml validation
Your mkdocs.yml could not be loaded, possibly due to a syntax error (line 18, column 19)
Line 18 in the mkdocs.yml config file is the section which calls the superfences python class
format: !!python/name:pymdownx.superfences.fence_div_format
Looking in the yaml specification https://yaml.org/spec/1.2/spec.html Shows that !! is for an explicit tag and it seems to have been part of the spec for quite some time ( back to version 1). I've tried making the value a string but this then causes issue with python reading it as a string
Does anyone know if readthedocs supports this or have you been able to get this working some other way?
ReadTheDocs is parsing the mkdocs.yaml file using pyyaml and it seems that it does not recognize !!.
For example:
>>> import yaml
>>> document = """
a: 1
b:
c: 3
d: !!4
"""
>>> print(yaml.dump(yaml.load(document)))
<stdin>:1: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 51, in get_single_data
return self.construct_document(node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 60, in construct_document
for dummy in generator:
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 218, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 143, in construct_mapping
value = self.construct_object(value_node, deep=deep)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
data = constructor(self, node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 427, in construct_undefined
raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:4'
in "<unicode string>", line 5, column 8:
d: !!4
^
>>>
See: https://github.com/readthedocs/readthedocs.org/issues/6889
I downloaded nltk tagset help is not working.
Whenever I try to access tagset meanings by:-
nltk.help.upenn_tagset('NN')
I get result as :-
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
nltk.help.upenn_tagset('NN')
File "C:\Python34\lib\site-packages\nltk\help.py", line 25, in upenn_tagset
_format_tagset("upenn_tagset", tagpattern)
File "C:\Python34\lib\site-packages\nltk\help.py", line 39, in _format_tagset
tagdict = load("help/tagsets/" + tagset + ".pickle")
File "C:\Python34\lib\site-packages\nltk\data.py", line 774, in load
opened_resource = _open(resource_url)
File "C:\Python34\lib\site-packages\nltk\data.py", line 888, in _open
return find(path_, path + ['']).open()
File "C:\Python34\lib\site-packages\nltk\data.py", line 618, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'help/tagsets/upenn_tagset.pickle' not found. Please
use the NLTK Downloader to obtain the resource: >>>
nltk.download()
Searched in:
- 'C:\\Users\\aarushi/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Python34\\nltk_data'
- 'C:\\Python34\\lib\\nltk_data'
- 'C:\\Users\\aarushi\\AppData\\Roaming\\nltk_data'
But I already downloaded tagset from models tab by nltk.download()
So what am I doing wrong here?
As nltk is telling you, it searched for the file help/tagsets/upenn_tagset.pickle in the directories:
- 'C:\\Users\\aarushi/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Python34\\nltk_data'
- 'C:\\Python34\\lib\\nltk_data'
- 'C:\\Users\\aarushi\\AppData\\Roaming\\nltk_data'
And could not find it.
Is it there?
If not, use nltk.download() to get it, and make sure it's in one of these directories.
https://i.stack.imgur.com/Ri7E2.png "Reference"
Hi ,
Check for above tagged image to summarize what exactly needs to be downloaded.
One of the fastest and easiest way to resolve this issue by downloading the help_tagsets from nltk.download() .
One can follow below steps:-
open your jupyter notebook or python shell in your OS(thru terminal).
ask for nltk.download() - (shell/jupyter) - it will open the GUI.
search the help_datasets in ALL PACKAGES column.
Just download it :-) Here you go .
I have big problem(s) with configuration of SciTE in context of Python 3. I do not know if details have any meaning, so:
[DETAILS]
I downloaded and executed gen_python_3_api.py.
I created folder "api" in usr/share/scite and copy-pasted there python3.api
I edited SciTEUser.properties as written in documentation of gen_python_3_api.py. It did not help a bit, so:
I used more general way found on website of SciTE. I edited python.properties and added a line:
api.$(file.patterns.py)=$(SciteDefaultHome)\api\python.api.
Still no effect.
I just edited another line of python.properties:
if PLAT_GTK
command.go.*.py=python3 -u "$(FileNameExt)"
It finally worked (or I though so).
[/DETAILS]
Now I want to run simple Fibbonaci program that worked well with IDLE.
def Fib(n):
a = 0
b = 1
FibL = []
for i in range (n):
FibL.append(a)
z = a
a = b
b = b+z
return FibL
n = int(input("Number? "))
print(Fib(n))
And I get:
>python3 -u "test.py"
Number? Traceback (most recent call last):
File "test.py", line 38, in <module>
n = int(input("Number? "))
EOFError: EOF when reading a line
>Exit code: 1
I am completely confused. Do somebody know why this things happen and how to fix it?
First of all, the generation of api is for editing only, not running your code.
Resolve the ambiguity with versions by adding full path to command lines (Hope, you do so in the 5th point of the question details)
The problem is in the line:
n = int(input("Number? "))
Here you want input from user, i.e. interactive running, but editor runs commands inside its process and can output simply.
Change your code by adding variable instead of the input command
n=5
or use parameters http://www.scintilla.org/SciTEDoc.html#property-if
Good luck!
The saltstack docs note the existence of the dns_check jinja filter in 2017.7.3:
{{ 'www.google.com' | dns_check }}
which should return an ip4v address as a string.
But when I try it:
test_this_one:
cmd.run:
- name: |
echo {{ 'www.google.com' | dns_check }}
I instead see
local:
Data failed to compile:
----------
Rendering SLS 'base:firewall' failed: Jinja error: dns_check() takes at least 2 arguments (1 given)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 418, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 42, in top-level template code
TypeError: dns_check() takes at least 2 arguments (1 given)
Am I missing something? I'm inclined to believe I've made a mistake rather than that the docs are so publicly wrong.
Looking at the source code it looks like dns_check now takes a port argument - the docstring says:
Tries to connect to the address before considering it useful. If no address can be reached, the first one resolved is used as a fallback.
https://github.com/saltstack/salt/blob/06a00be0e1f06399805e19261e4d00f6cfd9c6a0/salt/utils/network.py#L1750
So it's probably enough to put any port in here and it should work. (and perhaps an issue should be raised about making port optional?)