Pydiction <Tab> isnot popping up with code completion suggestions - python

I installed Pathogen
and followed http://rkulla.github.io/pydiction/ for installing pydiction
Configuration in my /root/.vimrc also I changed in the path which is given by :echo $MYVIMRC
My .vimrc file :-
filetype plugin on
let g:pydiction_location = '/root/.vim/bundle/pydiction/complete-dict'
let g:pydiction_menu_height = 3
But after these all instructions also I am not getting any suggessions ( by giving tab key) from complete-dict
If anything I left to configure please help me
when I am pressing C-N also in my vim file it is showing like this :-
-- Keyword completion (^N^P) Pattern not found

Related

How to use 7z from the python scripts

I have following syntax in my python script.
x = Popen("\"C:/Program Files/7-zip/7z\" a -tzip " + new_file + " general/*")
Can anyone please explain the meaning of this syntax?
From some forums, I am explaining my understanding.
First the 7z application will be started from the command line interface from the mentioned path. Then the folder " general" in the current directory will be copied into new_file. Am I right?
Please note, I am totally new to Python. Hence please excuse my understanding.
When I run this command, I am getting following Warning. Can anyone please let me know the issue in the syntax?
7-Zip 17.01 beta (x64) : Copyright (c) 1999-2017 Igor Pavlov : 2017-08-28
Open archive: <new_file>.zip
Path = <new_file>.zip
Type = zip
Physical Size = 93678166
Scanning the drive:
WARNING: The system cannot find the file specified.
general
Writing the path like this: "<path>" is valid? What is the difference between "" and "<path>"? Frankly speaking, I have copied this from some forum for my application.
What does " general/* " means? I know that if file name to be written with the space, it should be quoted with "". But what does it mean with wildcard characters " general/*"?
Please note, this scripts it going to be executed with Windows command line interface.
Thanks in advance.
When I run this command, I am getting following Warning. Can anyone please let me know the issue in the syntax?
WARNING: The system cannot find the file specified.
general
The reason for this warning is not in the syntax; it's because there is no folder named general.
Writing the path like this: "<path>" is valid?
It seems so, but you probably don't really want to have the file name contain less-than or greater-than characters (angle brackets). Presumably where you've copied this from there's a line
new_file = "<new_file>"
- you were supposed to replace <new_file> with a file name of your choice, but you didn't.
What does " general/* " means?
In this context it means that all files in the folder general are to be added to the zip file.

File content as PyCharm run configuration parameters

I'm trying to launch may main Python script with some arguments listed in a txt file (config.txt).
Because parameters change almost every launch and I dont want to type them every time. They are not literally a "config" but I didn't find the correct file name (that's an other story).
See below:
-param1 1
-param2 2
-verbose
Using Run Configuration of PyCharm.
I would like to finally do something like :
python C:\somewhere\main.py -param1 1 -param2 2 -verbose
Instead of current behavior :python C:\somewhere\main.py config.txt
Which, by the way, is missed understood by the program (obviously).
#32951846
I already tried windows for loops in the section "before launch: activate tools":
$: for /f "delims=" %x in (config.txt) do set ARGS=%ARGS%%x
$: python C:\somewhere\main.py %ARGS%
But it only keep the last line of the config.txt inside ARGS.
#51948712
I also tried to pipe the content of the file into my python main program like:
python C:\somewhere\main.py < config.txt
But it do not work neither.
#syntax-redirection
Am I right that you'd like to see something like https://youtrack.jetbrains.com/issue/PY-5543?
Consider using the following plugin: https://plugins.jetbrains.com/plugin/7861-envfile/
This is not exactly what you were asking for, but you can follow this guideline to store the run configurations in a file and then modify the file, share it or add to git.
The key steps are to tick the box "Store as project file" in PyCharm's "Run/Debug Configurations" window. This will create the new subfolder "runConfigurations" in the ".idea" folder in the project folder.
The folder will contain an xml file with the line
<option name="PARAMETERS" value=""arg1" "arg2"" />
where "arg1" and "arg2" are the arguments which are passed to your script.

pylint no member issue but code still works vscode

I have a very simple code here
import torch
l = torch.nn.Linear(2,5)
v = torch.FloatTensor([1, 2])
print(l(v))
under torch.FloatTensor, pylint in visual studio code claims that 'Module torch has no 'FloatTensor' member pylint(no-member).
However, the code works fine. Is this a false positive? How can I disable pylint for this specific instance?
Press: CTRL + Shift + P
Click on "Preferences: Open Settings (JSON)"
Add this line into JSON :
"python.linting.pylintArgs": ["--generated-members", "from_json,query"]
What worked for me was noticing what modules were giving those errors, which is torch for you, and then followed these steps:
hit CTRL + Shift + P
click on "Preferences: Open Settings (JSON)"
add the following to the JSON file you are presented with:
"python.linting.pylintArgs": [
"--generated-members", "torch.*"
]
for the sake of this answer, say that there were other modules giving problems, then you'd write:
"python.linting.pylintArgs": [
"--generated-members", "torch.* other_module.* next_module.*"
]
Yes it is a problem of Pylint
If you use Anaconda, you can do:
1. search python.linting.pylintPath in your VSCode setting
2. change it to (You Anaconda Path)\pkgs\pylint-1.8.4-py36_0\Scripts\pylint
You Anaconda Path and pylint-1.8.4-py36_0 may vary
A better answer to this question here: Why does it say that module pygame has no init member?
The answer above marked as the answer with references to Anaconda doesn't make sense to me, probably a newbie issue.
Please follow the link to get the real scoop, but to summarize -
Replacing extensionname with your problem module name, such as pygame or RPi or Torch:
Hit CTRL + Shift + P
Click on "Preferences: Open Settings (JSON)"
Add the following to the JSON file you are presented with (inside the {}, if there are entries already there add leading comma as well):
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
As Tomari says, it does work on windows.There is a little difference on linux. The path maybe like "(You Anaconda Path)/pkgs/pylint-2.6.0-py38_0/bin/pylint".

MacVim Python Indentation Issue

For the past 6 hours, I have been trying to find the source of an annoying bug in my MacVim setup. For reasons detailed below, the first time I opened up a Python file, the indentation was set correctly from the file $VIMRUNTIME/ftplugin/python.vim, which for me was /usr/local/Cellar/macvim/7.4-72/MacVim.app/Contents/Resources/vim/runtime/ftplugin.
However on every subsequent Python file load, the shiftwidth reverted to the global default of 2, which I have set in my .vimrc. In tracking down the issue, I finally came upon this code in the $VIMRUNTIME/ftpluin/python.vim file:
if exists('*<SID>Python_jump') | finish | endif
fun! <SID>Python_jump(motion) range
let cnt = v:count1
let save = #/ " save last search pattern
mark '
while cnt > 0
silent! exe a:motion
let cnt = cnt - 1
endwhile
call histdel('/', -1)
let #/ = save " restore last search pattern
endfun
if has("gui_win32") && !exists("b:browsefilter")
let b:browsefilter = "Python Files (*.py)\t*.py\n" .
\ "All Files (*.*)\t*.*\n"
endif
" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
On the first load, <SID>Python_jump isn't defined, so the PEP8 style indentation settings are applied. However, on every next load, the function is available and so the shiftwidth settings are never applied. If I comment out the if exists('*<SID>Python_jump') | finish | endif line, it works as expected and the indentation settings are set correctly on every file load.
Now, what I'm wondering is if this is a genuine problem faced by others as well; in which case I should probably fix it and open up a pull request on the MacVim repo, or do I have something else wrong? I have tried disabling every plugin (I use Vundle, so I just commented out their Bundle lines in my .vimrc), but the result is the same.
Edit
As pointed out by krystah, a au FileType python set shiftwidth=4 also fixes the issue.
I have the same issue. Putting the following line in .vimrc fixed it though.
au FileType python set shiftwidth=4

Do python files need to be on the same drive as the plugin Python-mode for its functionality to work

I'm using the plugin python-mode for gVim on a windows machine.
I have the following python-mode specific settings in my vimrc file:
"------------------------------------------------------------
" settings for Python-mode
" "-----------------------------------------------------------
map <Leader>g :call RopeGotoDefinition()<CR>
let ropevim_enable_shortcuts = 1
let g:pymode_rope_goto_def_newwin = "vnew"
let g:pymode_rope_extended_complete = 1
let g:pymode_breakpoint = 0
let g:pymode_syntax = 1
let g:pymode_syntax_builtin_objs = 0
let g:pymode_syntax_builtin_funcs = 0
map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
"Better navigating through omnicomplete option list
set completeopt=longest,menuone
function! OmniPopup(action)
if pumvisible()
if a:action == 'j'
return "\<C-N>"
elseif a:action == 'k'
return "\<C-P>"
endif
endif
return a:action
endfunction
inoremap <silent><C-j> <C-R>=OmniPopup('j')<CR>
inoremap <silent><C-k> <C-R>=OmniPopup('k')<CR>
These were suggested in this tutorial.
vimrc is on my M: drive.
Now if I open vim (set to open in the M: drive) and then open a python file on say the P: drive and then try to save that file I get the following error message:
If I move the file pi.py to the M: drive then everything is happy but surely to use files in vim it shouldn't be a condition that the file being edited is on the same drive as vim?
Can I change my settings for Python-mode to function on files from other drives?
EDIT
Python-mode has the following setting which looks promising:
" Additional python paths
let g:pymode_paths = []
So in vimrc I've added
let g:pymode_paths = ['P:\Comp Apps\Python\']
But still if I open a .py file from that location i get the same error message.
If I execute :lcd %:p:h then the python-mode plugin seems to be working. I can also use set autochdir in my vimrc: not sure if there are any disadvantages to using this setting.

Categories