What is the most complete way to install python on Windows?

Asked

Viewed 8,633 times

21

I know this question can be interpreted as an argument, so I did it with the word "complete" instead of "better".

I’m a python user on GNU/Linux and here it comes more or less pre-installed. Still, I can use Pip to install or remove new packages, creating a complete installation for my everyday use (virtualenv, scientific computing packages and other development libraries, like Tkinter).

I have seen many python questions on Windows (SOEN has many, some are starting to appear here on SOPT), and I know that there is a python version (both 2.7 and 3.x) for installation from the site of the language itself, as well as some packages for scientific computing.

I imagine the answer will depend on my application. Considering two different environments:

  • Scientific Computing (in this case, which of the two applications listed in the link above is the most complete?)

  • Business Development Environment (here, I have no idea)

What kind of tools exist for MS Windows that allow me to have a good python development environment, simply, quickly and completely?

And yet, there is something equivalent to PIP for Windows?

  • After all you want to have a python package manager in windows, whether it is Pip or not, right? I wonder why "What kind of tools exist for MS Windows that allow me to have a good development environment, simply, quickly and completely?" was very generic (and difficult to answer).

  • @Talles, I really need to learn to ask questions here... = P I will try to re-edit the question.

  • @Talles, edited.

  • I don’t understand, you asked "What is the most complete way to install python on Windows?" and then "What kind of tools are there for MS Windows that allow me to have a good python development environment, simply, quickly and completely?" and still "is there anything equivalent to PIP for Windows?" you basically asked 3 different questions.

  • When you’re on Linux for example, you usually already have Python installed by default, 2.7.x and 3.x, in your case, you said you use libraries for scientific computing, then you access the package manager and install the science-related computing packages. In Windows you will do basically the same thing. Download the desired version of Python on the official website, and install the PIP to install the desired packages that are in Pypi, the PIP is cross-platform according to what is written on their website, if the package is not in Pypi you will have to Inst. manually

  • @Zignd, yes, that’s three questions. But if you look closely, the question of the title is repeated once in the description of the question, since I detail what I want (environment for scientific computing and commercial production environment), and Pip is a bonus. By the way, thanks for the tip from Pip.

  • Simple comment: I did exactly the opposite here, I downloaded the latest Pyqt4 and Py 3 and I only put it in the uninstalled folders (I actually installed it in a "disposable" VM and only copied the definitive OS pro folders). It worked out that it’s a beauty (the intention was already to use even pre-compiled libs), I just had to associate the extensions . py and . pyw to . exe from Py in my code editor to test "the keystroke".

Show 2 more comments

5 answers

18


One of the biggest difficulties in installing Python packages on Windows is that not always the resources needed to compile them from sources are present. This causes problems when installing certain packages via PIP, so some manual intervention is needed.

In my personal experience (Python 2.7 on Windows XP), the steps to setting up a Python environment would be:

  1. Install your own Python official website;
  2. Install the setuptools, from a own binary for Windows;
  3. Install the Pip, from a own binary for Windows;
  4. Place the folder where the Pip is (eg.: C:\Python27\Scripts) in the PATH (optional);
  5. For every package you want to install:
    1. Try to install from Pip: pip install pacote.
    2. If installation error, search for a proper Windows binary on Google.

Unfortunately, from my personal experience I can say that this step 5.2 is more frequent than I would like... "Pure python" packages like Django usually install well through Pip, but those that require a native interface (usually via C) often fail frequently.

As for finding binaries, I usually just Google, but on that website has a very extensive list of binaries for both 32bit and 64bit Windows. Some of the packages I needed for commercial development (e.g.: Reportlab - PDF generation, psycopg2 - Postgres interface, mod-wsgi - Apache interface, etc.) as well as some scientific computing (Numpy, Scipy, Pyephem etc.) and many others are available on this list.

  • for packages that need C/C++, it would not be the case to have a C compiler installed on the system?

  • 1

    @Luizangioletti yes, but I don’t know if it would be enough. Many packages have dependencies the most to compile from the source rather than to simply use the package, so each case is a case. The advantage of pre-compiled is that someone has already taken the trouble to configure everything correctly and - presumably - confirm that it works well in the Windows environment. But if you have a compiler installed, and Python finds it correctly, etc., I think the installation via Pip will work without problems (or: fewer packages will present problems)

  • 1

    In addition to everything that @mgibsonbr, I think it is worth adding the installation of virtualenv that, for windows, is a little more complicated. Although virtualenv is only needed one pip install virtualenv, to install the wrapper it is necessary to mess with the Power Shell, as can be seen here. I also find interesting this tutorial as complementary reading, mainly because of the bonus part.

6

I advise you to study a little about Vagrant or some tool that will be able to provision several isolated environments of your operating system.

You might as well work on windows and your desktop is provisioned by a Ubuntu, for example.

www.vagrantup.com

www.docker.io

  • the idea is not to work inside Ubuntu, inside Windows. The question is precisely how to work independently of Ubuntu (or Linux in general) within Windows. I’ll take a look at Vagrant, but his answer doesn’t answer the question, so any downvotes.

  • Take a look at Vagrant and you’ll see that the answer answers your yes question. ;) Vagrant creates a virtual machine (virtually invisible) and isolates its operating system from its development environment (testing, production, etc.). Then you will be free to set up your machine the same way you did on Linux and work with it on Windows. All of this without much effort.

  • +1 Although not the solution desired/expected by OP, Vagrant actually answers the question "how to get a full Python environment in Windows", and is used by some developers.

2

I’ve come to quote the Anaconda.

Anaconda is a completely free Python distribution (including for commercial use and redistribution). It includes more than 195 of the python packages most popular for science, math, engineering, data analysis.

This distribution comes with Spyder IDE, which resembles the MATLAB interface.

Python versions available: 2.7 and 3.4

1

I would like to quote the Chocolatey, a package manager for windows offering an experience similar to that of package managers in linux, its installation is simple just copy the command below and run it in CMD

@"%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"

After that just use the command choco search python CMD or Powershell to list available packages. As well as choco install python to install python version 3 with basic utilities.

1

In the main implementation of the Python language, Cpython, also known as "reference implementation", the interpreter is written in... guess what?! C.

Cpython is also famous for allowing easy access to C libraries, either when there is a need for performance optimizations, or serving as a "glue" language between low-level libraries.

And then the community uses this resource a lot... lacked performance? Goes down to the C, and goes on living. So it is with PIL, Pycrypto, simplejson, to name a few. Fantastic!

Who program in an environment where the gcc It is available becomes easy, there is no disorder. But who needs to use Windows suffers a lot, because Cpython on this platform is compiled officially in MS Visual Studio.

When installing a package that has C code, the installation process will attempt to automatically find a compiler. If you don’t have a configured compiler, you get an error similar to this:

Error

Unable to find vcvarsall.bat

The solution is either to get a binary version of the package (with an executable installer that you simply click on Next, Next, Finish!), or set up a compiler on your machine.

If you intend to develop in Python, I strongly recommend having a compiler installed. The options in Windows are: Visual Studio or the MinGW. As a compiler, the very Pip takes charge of requesting the build from the sources, it is much easier to search for a binary*.

I have a post about installing Python on Windows and setting up a compiler: http://fernandomacedo.com/programacao/instalando-python-no-windows

  • Some projects are hard at work to compile because they depend on other libraries that need to be in the environment, but they’re not the majority, and you can always turn to a binary distribution if Pip doesn’t work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.