Windows 7 -
I'm a fairly new Windows person and am trying to get a nice setup with Vim, Ultisnips, and more in the console. To get Ultisnips working, it appears I need python support in Vim. I have installed Python 2.7.9 (and other later versions) and reinstalled Vim74 multiple times, but python shows as -python, -python3 in vim's version report.
Now GVim does show python support, but running vim from git bash does not. See screenshot.
In GVim, when I do :python import sys; print(sys.version), it shows
2.7.9 (default, Dec 10... etc) Is it reflecting the preferred Python it needs, or just what I have installed?
I would love to use vim in the console/terminal with Ultisnips.
Do I have to install Vim in a special way? Or set something in _vimrc? The console vim also doesn't display :help either (gvim is fine), but that's another issue (related?)
I have spent a good chunk of time looking at relevant articles, but can't get it to work. Thanks for any advice!
python config screenshot
Try to put settings in .gvimrc/_gvimrc beside the .vimrc/_vimrc file.
For the help about gvimrc type :h gvimrc when in command mode in vim.
If the gvimrc files exist, they are used to configure Vim when the GUI version (gvim) runs (after settings from vimrc are applied).
Settings for gvim can also be placed in the vimrc file using a has('gui_running') check:
if has('gui_running')
set guioptions-=T " no toolbar
colorscheme elflord
endif
The console vim command was apparently running a copy of vim in the Git directory, where it seems to be missing a bunch of things including /doc, hence the 'help' not working. I can now run vim in the program files directory via console, where it now shows python support, and help etc.
Related
I have been trying to change my python interpreter on sublime text and VS code and no matter what I do, both of them refuse to change. It always picks the default Python 2.7 version.
On sublime, I tried to create a new build tool, added the path to Python3 but nothing is working.
And on, VS code, even if I select Python3 from the drop-down menu, it doesn't change anything.
I changed the system's default python interpreter from 2.7 to 3.9 and set the path on bash profile. It fixed the issue for me.
I don't know about Sublime, but for VS Code, there looks to be quite a few things to verify:
Check your User Settings on whether you've set up a default interpreter for your applications
Are you using Window 10 WSL? Then you might want to check out issue 3227 for vscode-remote-release where the comment was:
So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python.
For Sublime, you need to hit ⌘B with your script pane focused in order to use your new python3.sublime-build build system.
It looks like you are running your script within Terminus, which is fine, but you need to use the python3 command when running it from the command line, even if that command line is within Sublime.
Please check out my answer here on how to make a Python build system that accepts user input, as the Sublime "console" doesn't allow you to interact with your program. Since you already have Terminus installed, I'd recommend going down to the bottom of the answer and using the Terminus build system. That way, you won't have to deal with Terminal windows opening every time you run a build.
The terminal window uses your PATH, not the IDE settings, so manually typing out python --version isn't testing anything except the PATH variable
In order for the terminal to use the "correct" python binary you've specified, it would need to give the absolute path to it, which I believe using Command+B (using the build options) in Sublime would do. Similarly, you can use the Run/Debug Configurations in VSCode.
Or you can modify your ~/.zshrc to fix your PATH, for example installing pyenv to change the entire system Python version, or the one for the current folder
I've been messing around with AutoHotKey, trying to create some useful shortcuts for myself. I can open file explorer, calculator, chrome, etc., but I haven't been able to write a program that opens Python IDLE.
My program says:
!t::
Run pythonw
return
I've tried pythonw.exe, python.exe, python, python3.exe, and a bunch of other combinations. Any idea why it isn't working? Thanks!
So, your problem is that Python IDLE is different from pythonw.exe, python.exe, python, python3.exe .
Python IDLE is an IDE or Code Editor provided with python whereas pythonw.exe, python.exe, python, python3.exe are the python interpreter.
pythonw.exe - for executing python scripts without opening console window(Hidden)
python OR python3.exe OR python3.exe - are the same, that is the normal python interpreter.
So to open IDLE you should execute the IDLE file not the interpreter.
The path for IDLE(in Windows Computer) is usually :
C:\Python39\Lib\idlelib\idle.bat
Here the Python version is 3.9 but it may be different in your case!
Check for the version you installed by opening command prompt and typing :
C:\>python --version
Python 3.9.1
Turning the info that Jaysmito provided into an AutoHotkey Script:
!t::
Run C:\Python39\Lib\idlelib\idle.bat
return
However, the Python39 part of the directory above will vary based on which version of python you have installed. To check which version of Python you are using, use the python --version command in a command prompt window. Then if your version of Python is not in the 3.9.* range, change the directory above to match your version.
For example, if your version is in the 2.7.* range, your directory would be something like Run C:\Python27\Lib\idlelib\idle.bat, with the Python39 from above changed to Python27.
idle.bat is Windows specific, and there are Windows-specific reasons for its existence. The generic way to start IDLE in its default startup mode (partly user customizable) is somepython -m idlelib where somepython refers to and start a python binary. It can be python, pythonw (Windows), python3 (*nix), or py -3.y (Windows). For 2.x, use idlelib.idle instead of idlelib.
I currently have python 2.7.6 and 3.4.0 installed. Whenever I rightclick and open with idle, and I try to run it in idle, the version used in 2.7.6. However, I need it to run in 3.4.0. I can work around this issue by opening idle manually and opening a file from idle itself, but this is pretty tedious and I'm wondering if anyone knows a solution to this issue?
You did not specify OS; I suspect Windows and am answering from a Windows 7 perspective. Most entries in the right click menu corresponds to a command line, with the file name substituted for a wildcard placeholder. (Exceptions include cut and `copy'.) Some entries are present for all files. Some, such as this one, are specific to a type of file as indicated by the extension. The right-click menu is governed by the Windows registry.
When multiple versions of Python are installed, one is designated as the default version. If I wanted to change the designation (to 3.4, for instance), I would either go to Control Panel, Programs and Features and 'change' the Python 3.4 installation, or just re-install it from the installer.
If you do not want to do that, you can 'Edit with Idle' (2.7) and the file will then appear under File -> Recent Files on the 3.4 menu.
I have considered requesting that there be an "Edit with Idle x.y' entry for each Python version installed. I do not know if there are techical reasons preventing that.
Sorry I am a Python beginner and after several months with Python(GUI) I now want to move to Komodo IDE 8.5 (Suggested by posts on this forum), but I had trouble on configuring it to proper use. The main issue is how I can run a Python program in Komodo like in IDLE(Python GUI) using Run Module (pressing F5) feature?
When I pressed F5 in Komodo IDE 8.5, I got message "No Python interpreter is available".
I am using Python 3.30. Python.exe is in this path "D:\1_tools\python". Komodo.exe is in this path "D:\1_tools\komodo_IDE"
Thanks for any kind helpers. I have searched the forum but did not get any helpful info. Thanks again.
There is a thread on the Komodo Community Site that discusses this exact situation. (http://community.activestate.com/node/10113)
Sumarizing:
It seems that Komodo IDE defaults to using Python2 and since it can't find a Python2 interpreter, it complains.
Solution:
For existing files, the suggested solution is to tell Komodo IDE (via "Properties and Settings" on the Editor Tab) that the file uses the Python 3 interpreter.
If you create all new python source files using the Python3 template, the IDE will be able to run them. Beware: The first time you want to use the Python3 template you will have to create the new file using the menu: "File" -> "New" -> "File from Template", then select the Python 3 template.
Is Python on your PATH? That is, if you open a command prompt and type python by itself, does it run? In Komodo, look under Edit/Preferences/Languages/Python3 and check the configuration. If python.exe is not on your PATH you can provide the full path to it there
My command prompt is currently running Python 3.2 by default how do I set it up to run Python 2.7 by default, I have changed the PATH variable to point towards Python 2.7, but that did not work.
UPDATE:
It still does not work. :(
Still running python3 - to be specific it runs python3 when I am trying to install flask - which is what I want to do.
More generally, when I simply type python into the command line, it does nothing.
I get a 'python' is not recognized as an internal or external command, operable program, or batch file error.
No idea what to do.
If you call your Python scripts directly using python script.py then setting the PATH to have the 2.7 directory first should be enough.
If you want to call Python scripts indirectly with the shell, i.e. by writing just script.py or by executing the file from the explorer, you need to set the 2.7 installation as the default program handler for the .py extension. The easiest way to do that is to run the Python installer again and choose the option “make this installation the default”.
Note that with the new launcher, that ships with 3.3+, you don’t need this, as you can specify the version number using a shebang line and the launcher will automatically pick the appropriate interpreter.
Changing your PATH environment variable should do the trick. Some troubleshooting tips:
Make sure you didn't just change the local, but rather the system variable to reflect the new location
Make sure you restarted your CL window (aka close "cmd" or command prompt and reopen it). This will refresh the system variables you just updated.
Make sure you remove all references to C:\Python32\ or whatever the old path was (again, check local and system PATH - they are both found on the same environmental variables window).
Check to see if Python3.2 is installed where you think it is... (just rename the directory to something like OLD_Python3.2 and go to your CLI and enter "python" - does it start up? If it does is it 2.7? or 3.2? If not, you did something wrong with your PATH variable.
All else fails - reboot and try again (you might have some persistent environment variable - which I don't see how that can be - but hey, we are brainstorming here! - and a reboot would give you a fresh start.
If that doesn't work then I'd think you are doing something else wrong (aka user error). CMD has to know where to look for python before it can execute. It knows this from your PATH variable... now granted, I work almost exclusively in 2.6/2.7, so if they did something to the registry (which I doubt) then I wouldn't know about that.
Good luck!
Change the two las lines to you current python desired build path:
Windows Registry Editor Version 5.00
' Extracted from Python 2.7 silent installation By Elektro H#cker
[HKEY_CLASSES_ROOT\.py]
#="Python.File"
[HKEY_CLASSES_ROOT\.pyc]
#="Python.CompiledFile"
[HKEY_CLASSES_ROOT\.pyo]
#="Python.CompiledFile"
[HKEY_CLASSES_ROOT\.pyw]
#="Python.NoConFile"
[HKEY_CLASSES_ROOT\Python.File\Shell\Open\Command]
#="CMD /K \"\"C:\\Program Files (x86)\\Python\\Python.exe\" \"%1\" %*\""
[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open\command]
#="CMD /K \"\"C:\\Program Files (x86)\\Python\\Pythonw.exe\" \"%1\" %*\""
Could you try this as root:
$ ln -s python2.7 /usr/local/bin/python
Logout & login again as root:
$ python -V
It works for me, hoping the same to you.
Cheers,