I want to use chocolately to install numpy onto a Windows machine.
However when I run:
choco install numpy
it tried to install a numpy for Python 3.
How can I force it to install a version for Python 2?
I want to use chocolately to install numpy onto a Windows machine.
However when I run:
choco install numpy
it tried to install a numpy for Python 3.
How can I force it to install a version for Python 2?
How do I install
numpy
for Python 2 withchoco
?
Run choco install numpy
.
When I ran
choco install numpy
, it tried to installnumpy
for Python 3. How can I force it to install a version for Python 2?
The trick here is that if you look at the chocolateyinstall.ps1
and chocolateyuninstall.ps1
files for the Chocolatey numpy package you've linked to (under Files
), the package itself simply uses the version of Python installed on your system, along with Python's pip
package manager, to install and uninstall Python packages.
Therefore, the simplest way to handle this is to:
Add Python 2.7 (e.g. C:/path/to/Python27
) your Windows path variable(s) and remove/rename any entry for e.g. Python 3.7.
Log off and then back on to reload your path variable(s). Open a command prompt and check that python -V
returns e.g. Python 2.7.16
.
Run choco install numpy
. Say no to installing e.g. Python 3.7 and yes to installing numpy
. As long as there is an entry in green that says numpy
was installed successfully, you can likely ignore any other messages/errors.
To verify that numpy
was installed successfully, run python
from a command window and enter import numpy
at the interactive >>>
prompt. If there is no error message, numpy
has been imported successfully.
Caveats
This method obviously relies on Python 2.7 being the default python
on your system. If this changes, you may run into issues in the future.
Notes
Alternatively, since Chocolatey is simply using pip
in the background, you can use e.g. C:/path/to/Python27/python.exe -m pip install numpy
to install numpy
directly (minus an entry in Chocolatey).
python
(i.e. Python 3 isn't in your path or you taken other "mitigating" steps such as renaming the Python 3 executable), there should be no need for that particular step.
Commented
Jul 9, 2019 at 7:53