Vim for Windows: Python doesn't load properly / “crashes” - windows

I've been struggling for 2 days to install some plugins which use python on Vim (Windows). Even with a stock vimrc.
Using the official vim 7.4 binary (x86)
I've checked that it comes with +python/dyn and +python3/dyn
I've installed Python 2.7.10 x86, and appended python's path in my Path environment.
:echo has('python') prints 1 as expected.
Yet: when I type :python print 'test', vim quits, just as if I've typed :q
:python mum tell me, why does windows exists?, it quits as well. Wondering why... Not a print issue at least.
Using tuxproject's nighty builds of vim 7.4.826 (x86)
It does come with +python/dyn and +python3/dyn. Also:
Used libraries: Perl 5.22.1, Python 2.7.10, Python 3.4.3, Ruby 2.2.3, Lua 5.3.0, Tcl 8.6.4, libXpm.
Great! That's the verison I've downloaded (2.7.10) ! Wait...
:echo has('python') prints 1 as expected.
But, "merry christmas!" says vim.
Sorry, this command is disabled, the Python's site module could not be loaded. Windows isn't good enough. Oh, and merry christmas!
Using tuxproject's nighty builds of vim 7.4.826 (x64)
I tried to use x64's python binary, taking care of removing the x86 version from my Path variable. Same issue as above.
Using Kaoriya's vim 7.4.something (x64) and Veegee's vim 7.4.803
Same issue as above.
What about compiling vim ?
Windows.
I'm not that lazy, well, yes I am... but I'll try to compile it if there isn't any other workaround. I don't really want to compile it if it won't solve anything. If only I could at least understand why these issues happen...

All right, I managed to solve the issue.
For those who may be interested, the intended python version was Python 2.7.9 and not 2.7.10. Installing Python 2.7.9 x86 (and x64) fixed everything for the corresponding vim version.

First of all, need to check for the python version compiled into the vim. One of the way is to edit the gvim executable (e.g. for window it's gvim.exe), and look for "python\d*.dll\c" as mentioned inside the vim manual. Nonetheless, when you run :echo has('python3') || has ('python'), it may give you the hint that vim cannot find and load python27.dll or python32.dll, so you can guess the python get compiled with vim in this way as well.
Once you have identified the python version needed, and if your python is installed on another location, then you can specify the pythonthreedll location to let vim to find it.
:set pythonthreedll=D:\installed\python\python35.dll
check again with following:
:echo has('python3')

I have this problem too but I didn't have to install previous versions.
All I do to solve this is just set PYTHONHOME=C:\Users\MYUSERNAME\Anaconda2 in my system environment variables!
You may have to adjust the location if you did not use Anaconda as a python installer.
Note: I use python 2.7.11 and 3.5 (Both of them are installed via Anaconda 64-bit)
PS. Please ensure that PYTHONHOME is typed correctly, no underscores. And it should point to the location of Python 2 only. Don't point to Python 3 folder.
PPS. It turns out that if you set PYTHONHOME, your working python3 command on the terminal will crash, so I do not suggest this anymore.

Related

How to install GnuPlot on windows?

A Unix (mac/Linux) user who has been forced to work on a windows machine here :)
I have scripted loads of work in GnuPlot and don't want to switch to other programs at this moment. I would appreciate it if you could help me know how to install GnuPlot On windows (more specifically windows 10). questions:
I know there are two options according to this page, Cygwin and MinGW. which one is better?
I have MinGW installed and I know I need to install one of the options from this page but I don't know which one(s)! and how.
I have searched the internet but it seems most of the search results are for compiling. I don't want to go through compiling and all the hassle.
I tried installing the binary from this link, and when I try to run the program this is the error I get:
Unable to execute file:
C:\Program Files\gnuplot\bin\wgnuplot.exe
CreatProcess failed; Code267.
The directory name is invalid.
I would appreciate it if you could give me a very simple stepwise installation (1 2 3 ...), preferably with visuals, and instructions.
P.S. A nice way to install Free, Libre, and Open Source Software (FLOSS) on Windows and keep them updated, is to use package managers like Chocolatey. There are GnuPlot chocolatey packages here. Just install choco as instructed here. Then use choco install Gnuplot to have the software installed.
You don't have to install MinGW or Cygwin. Actually packages compiled in MinGW are compatible with Windows. Just download the binary of gnuplot from Their repo and you are good to go.
Additional points:
When installing, check which terminals you want to set up; also
check if you want the installer to add the PATH variable to your
system. Also, create a desktop shortcut.
After installation, you should see the desktop shortcut. Clicking on it should open a terminal-based gnuplot (which hopefully you are familiar with).
Please note that I have used the x11 terminal (you can get this working by installing xming). There are other options such as windows and qt terminals, but I am not an expert on using these.
You should have Administrator rights on this machine.
Right click on MinGW, Run as Administrator, install - should be OK.
Good luck!
BR, Alex
You can try
$~ scoop install gnuplot
Installing 'Gnuplot' (5.4.5) [64bit] from main bucket
gp545-win64-mingw.7z (37.7 MB) [=======================================] 100%
Checking hash of gp545-win64-mingw.7z ... ok.
Extracting gp545-win64-mingw.7z ... done.
Linking ~\scoop\apps\Gnuplot\current => ~\scoop\apps\Gnuplot\5.4.5
Creating shim for 'gnuplot'.
Creating shortcut for GNUPlot (wgnuplot.exe)
'Gnuplot' (5.4.5) was installed successfully!

Having difficulty running pygame 2.7

Every time I try to run Pygame 2.7 version I get this prompt:
Windows cant open this file:
File name: pygame-1.9.2b1-cp27-cp27m-win_amd 64.whl
To open this file Windows needs to know what program you want to use to open it.
Windows can go online to look it up automatically, or you can manually select from a list of programs that are installed on your computer.
What do you want to do?
Use the Web service to find the correct program
Select a program from a list of installed programs
How can this be solved?
I've tried many Youtube videos.
That .whl file that you mention needs to be installed with a command-line tool called pip that comes with python. Assuming you are starting from scratch, here is what you need to do to install python and pygame. Also, as a minor sidenote, you are actually installing pygame 1.9.2 on python 2.7. Assuming you are interested in that particular version of python and pygame, here are the steps you need to follow.
To install python 2.7, you need to first go to the Python Software Foundation's website here. Go to the download section by clicking on the latest link for python 2.7.12. Scroll down and download either the x86 or x86-64 MSI installer (depending if you are on a 32bit or 64bit platform respectively).
Run the MSI installer. Most of the default options should be fine, nothing too tricky here.
After you run the installer, you need to add python to the PATH environment variable so that windows actually knows where python is on your computer. To do this, you need to find the Advanced System Settings section in your control panel (how to exactly get there varies depending on what Windows version you are on).
Once you are there, click the Environmental Variables... button. Under System Variables, we need to edit the value of the Path variable to include C:\Python27\ at the end of it. If all of the path variable stuff is on one line, you need to add a semicolon to separate it from the other paths in the list.
Congrats, now python 2.7 should be installed at this point! To test it out, open up the command prompt and type python. It should open up the interpreter in the command line and should be working.
Assuming it is working, exit out of the python interpreter. In the command prompt, type python -m pip install pygame. This should automatically install pygame for you. If you really want to use your wheel file, cd to the directory where it is installed and type python -m pip install pygame-1.9.2b1-cp27-cp27m-win_amd 64.whl.
Once that is done, you should have both python and pygame installed! Test it out in your IDE of choice (I personally use Geany) and start writing some code! Let me know if these instructions are clear enough.

How to install and use "make" in Windows?

I'm following the instructions of someone whose repository I cloned to my machine. I want to use the make command as part of setting up the code environment, but I'm using Windows. I searched online, but I could only find a make.exe file, a make-4.1.tar.gz file (I don't know what to do with it next) and instructions for how to download MinGW (for GNU; but after installing it I didn't find any mention of "make").
How do I use make in Windows without a GNU compiler or related packages?
make is a GNU command so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:
The most simple choice is using Chocolatey. First you need to install this package manager. Once installed you simlpy need to install make (you may need to run it in an elevated/admin command prompt) :
choco install make
Other recommended option is installing a Windows Subsystem for Linux (WSL/WSL2), so you'll have a Linux distribution of your choice embedded in Windows 10 where you'll be able to install make, gccand all the tools you need to build C programs.
For older Windows versions (MS Windows 2000 / XP / 2003 / Vista / 2008 / 7 with msvcrt.dll) you can use GnuWin32.
An outdated alternative was MinGw, but the project seems to be abandoned so it's better to go for one of the previous choices.
GNU make is available on chocolatey.
Install chocolatey from here.
Then, choco install make.
Now you will be able to use Make on windows.
I've tried using it on MinGW, but it should work on CMD as well.
The accepted answer is a bad idea in general because the manually created make.exe will stick around and can potentially cause unexpected problems. It actually breaks RubyInstaller: https://github.com/oneclick/rubyinstaller2/issues/105
An alternative is installing make via Chocolatey (as pointed out by #Vasantha Ganesh K)
Another alternative is installing MSYS2 from Chocolatey and using make from C:\tools\msys64\usr\bin. If make isn't installed automatically with MSYS2 you need to install it manually via pacman -S make (as pointed out by #Thad Guidry and #Luke).
If you're using Windows 10, it is built into the Linux subsystem feature. Just launch a Bash prompt (press the Windows key, then type bash and choose "Bash on Ubuntu on Windows"), cd to the directory you want to make and type make.
FWIW, the Windows drives are found in /mnt, e.g. C:\ drive is /mnt/c in Bash.
If Bash isn't available from your start menu, here are instructions for turning on that Windows feature (64-bit Windows only):
https://learn.microsoft.com/en-us/windows/wsl/install-win10
Download make.exe from their official site GnuWin32
In the Download session, click
Complete package, except sources.
Follow the installation instructions.
Once finished, add the <installation directory>/bin/ to the PATH variable.
Now you will be able to use make in cmd.
Install Msys2 http://www.msys2.org
Follow installation instructions
Install make with $ pacman -S make gettext base-devel
Add C:\msys64\usr\bin\ to your path
On windows 10 or 11, you can run the command winget install GnuWin32.Make in the command line or powershell to quickly install it. Than you can use the command cmake.
There is no need to install choco anymore.
The chances are that besides GNU make, you'll also need many of the coreutils. Touch, rm, cp, sed, test, tee, echo and the like. The build system might require bash features, if for nothing else, it's popular to create temp file names from the process ID ($$$$). That won't work without bash. You can get everything with the popular POSIX emulators for Windows:
Cygwin (http://www.cygwin.org/) Probably the most popular one and the most compatible with POSIX. Has some difficulties with Windows paths and it's slow.
GNUWin (http://gnuwin32.sourceforge.net/) It was good and fast but now abandoned. No bash provided, but it's possible to use it from other packages.
ezwinports (https://sourceforge.net/projects/ezwinports) My current favorite. Fast and works well. There is no bash provided with it, that can be a problem for some build systems. It's possible to use make from ezwinports and bash from Cygwin or MSYS2 as a workaround.
MSYS 1.19 abandoned. Worked well but featured very old make (3.86 or so)
MSYS2 (https://www.msys2.org/) Works well, second fastest solution after ezwinports. Good quality, package manager (pacman), all tooling available. I'd recommend this one.
MinGW abandoned? There was usually MSYS 1.19 bundled with MinGW packages, that contained an old make.exe. Use mingw32-make.exe from the package, that's more up to date.
Note that you might not be able to select your environment. If the build system was created for Cygwin, it might not work in other environments without modifications (The make language is the same, but escaping, path conversion are working differently, $(realpath) fails on Windows paths, DOS bat files are started as shell scripts and many similar issues). If it's from Linux, you might need to use a real Linux or WSL.
If the compiler is running on Linux, there is no point in installing make for Windows, because you'll have to run both make and the compiler on Linux. In the same way, if the compiler is running on Windows, WSL won't help, because in that environment you can only execute Linux tools, not Windows executables. It's a bit tricky!
I could suggest a step by step approach.
Visit GNUwin
Download the Setup Program
Follow the instructions and install GNUWin. You should pay attention to the directory where your application is being installed. (You will need it later1)
Follow these instructions and add make to your environment variables. As I told you before, now it is time to know where your application was installed.
FYI: The default directory is C:\Program Files (x86)\GnuWin32\.
Now, update the PATH to include the bin directory of the newly installed program.
A typical example of what one might add to the path is: ...;C:\Program Files (x86)\GnuWin32\bin
Another alternative is if you already installed minGW and added the bin folder the to Path environment variable, you can use "mingw32-make" instead of "make".
You can also create a symlink from "make" to "mingw32-make", or copying and changing the name of the file. I would not recommend the options before, they will work until you do changes on the minGW.
I once had the same problem. But I am surprised not to find one particular solution here.
Installation from GnuWin32 or via winget are good and easy options. But I only found make 3.8.1 there. This version lacks the very important option -O, which handles the output correctly when compiling multithreaded.
choco appears to offer make 4.3, currently. So one could expect recent versions there.
But there is also the option of self compiling. And if you have to install make, which is used for compiling, this should be a valid option.
head to https://www.gnu.org/software/make/ and download a version of your liking
unpack the tar.gz files (use 7zip and unpack the file twice to retrieve the actual content)
navigate to the created directory
open command prompt in that directory
run build_w32.bat gcc This will start the compilation with the gcc compiler, which you would need to install in advance. When running build_w32.bat without any option they try to use the MSVC compiler. Sidenote: I found it surprising that gnu does not use gcc as default but MSVC :-)
ignore the warnings created during compilation. The result should still be fine
retrieve your fresh gnumake.exe from the directoy GccRel (when compiled with gcc)
put this file somewhere where you like and rename to make.exe
add the location to the system variable %PATH%
As others have noted: This manual installation might cause conflicts if you have various make versions installed by other programs as well.
You can also install scoop, then run:
scoop install make
One solution that may helpful if you want to use the command line emulator cmder. You can install the package installer chocately. First we install chocately in windows command prompt using the following line:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
refreshenv
After chocolatey is installed the choco command can be used to install make. Once installed, you will need add an alias to /cmder/config/user_aliases.cmd. The following line should be added:
make="path_to_chocolatey\chocolatey\bin\make.exe" $*
Make will then operate in the cmder environment.
Install npm
install Node
Install Make
node install make up
node install make
If above commands displays any error then install Chocolatey(choco)
Open cmd and copy and paste the below command (command copied from chocolatey URL)
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Set up Vim to work with R and Sweave in Windows

I have installed vim in windows and would like to configure it so i can send code to R. I want to also use Sweave with it. However, i have Googled and failed to find clear step-by-step instructions on how to set this up.
my attempts so far:
installed Vim using executable from ftp://ftp.vim.org/pub/vim/pc/gvim73_46.exe
downloaded R-plugin from https://github.com/jcfaria/Vim-R-plugin/zipball/master and extracted it to a folder on my pc. following instructions in the r-plugin.txt file, i installed python-3.2.msi and pywin32-216.1.win32-py3.2exe. I extracted the plugin zip-file to C:\Program Files (x86)\Vim\vimfiles\ merging like-named folders together. then i opened Vim and typed :helptags C:\Program Files (x86)\Vim\vimfiles\doc. I closed Vim then I started R and reopened Vim. I typed :new anewfile.R and got the error message
"Python interface must be enabled to run Vim-R-Plugin. Please do ':h r-plugin-installation details
and when i type this i get
error149, no help for r-plugin-installation
I also did not see the buttons that send code to R.
I failed to understand the instruction that , "You may have to
adjust the value of |vimrplugin_sleeptime|."
What should i do?
-I already have Miktex 2.9 on my PC. will Vim see it? How do I set up Vim to see Latex?
Will appreciate any help.
Note: I have used rstudio with Sweave and also eclipse but there are some issues i need to resolve and hence need to try vim and see how it will work out.
I suppose that this solution will not satisfying you completely but Rstudio IDE features a basic VIm editing mode: Global Option > Code Editing > Enable vim editing mode.
I think the windows binaries of Vim 7.3 need Python 2.7 or 3.1. You can check the information that you get via :version; the linked Python version is somewhere in it.
So my solution would be installing Python 2.7 (+pywin32 for python 2.7). Also, check if Python is working in Vim before trying to use the R plugin.

How can I upgrade the *console* version of vim on OS X?

I'm sure this is a newbie question, but every time I've compiled/dl'ed a new version of vim for os x, running vim on the command-line opens up the gvim app. I just want to upgrade the console version (so I can, for example, have python compiled in to use omnicomplete).
If I understsood the question correcty, here is another solution: check out http://www.andrewvos.com/2011/07/23/upgrading-vim-on-os-x-with-homebrew/
Really simple, fast, painless. It uses homebrew-alt and you also need to have mercurial installed (it will prompt you if not).
You can also use MacPorts to handle the installation for you. Once you've installed it, run the /opt/local/bin/vim binary. I place this in my PATH before the system binary dirs (although be aware that this may cause problems for cmdline tools that rely on the versions of tools shipped with OS X).
This may sound stupid, but are you copying the vim binary to /usr/bin? by default, the "vim" path is /usr/bin/vim. If you compile from source, you'll likely need to either copy the vim binary to /usr/bin/vim (thus overwriting the original vim), or launch the compiled version via absolute path (eg. ~/vim-checkout/build/vim).
that's just a guess, however. I can't see it being anything more than that.
With Homebrew:
brew install macvim
ln -s /usr/local/bin/mvim /usr/local/bin/vim
Can also symlink your new binary to /usr/local/bin/

Resources