Skip to content

Installing pomdp‐py on Windows

Kaiyu Zheng edited this page Nov 5, 2021 · 1 revision

Install Python for Windows

Go to Python Releases for Windows

Download the release you want. Note that you should download a version with Windows Installer. That makes things easy. I downloaded 3.8.10.

Once you opened the Python Windows Installer, click on "install now" and wait till it finishes.

Now in the launcher, you can searchfor Python 3.8, and it will open up a CMD shell that looks like

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

To select 3.8.10 as the default Python version, look at this Stackoverflow answer, pasted below:

  1. Go to This PC -> Right-click -> Click on Properties -> Advanced System Settings.
  2. You will see the System Properties. From here navigate to the "Advanced" Tab -> Click on Environment Variables.
  3. You will see a top half for the user variables and the bottom half for System variables.
  4. Check the System Variables and double-click on the Path (to edit the Path).
  5. Check for the path of Python (which you wish to run i.e. Python 2.x or 3.x) and move it to the top of the Path list.
  6. Restart the Command Prompt, and now when you check the version of Python, it should correctly display the required version.

For step 5, if the path for Python does not exist in the list in Path, then you can add your own:

  1. Get the path to your Python 3.8.10 installation. You can do that by typing "Python 3.8" in the laucher, right click and select "Open file location". In the pop-up window, right click on the Shortcut for Pythohn 3.8 (64-bit), click Properties. In the pop-up window, the Python installation path is in Target. In my case, it is "C:\Users\kaiyu\AppData\Local\Programs\Python\Python38\python.exe"

  2. In the "Edit environment variable" window for Path, add two new paths by clicking "New":

    • C:\Users\kaiyu\AppData\Local\Programs\Python\Python38
    • C:\Users\kaiyu\AppData\Local\Programs\Python\Python38\Scripts

    (Note that the actual path depends on your system. Remember to include both the path to Python38 and the path to Python38/Scripts.

The result is, if you type python in CMD (Windows Command Prompt), we get a Python 3.8.10 shell:

C:\Users\kaiyu\Projects>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Using pip on windows

Check if pip is already installed:

  1. Run CMD
  2. Run pip help

If pip is not installed, follow instructions here to install it.

Using virtualenv on windows

Installation. Check if virtualenv is a valid command in CMD. If not, run

pip install virtualenv

to install it. virtualenv.exe will likely now be found in your python installation directory under the Scripts subdirectory (ref).

Creating a new virtualenv. If the path to Scripts is in your Windows PATH variable, then virtualenv should be available as a command. If not, you could run virtualenv by

python -m virtualenv [args...]

For example, I created a virtualenv for python 3.8.10 (-p python because python by default points to Python 3.8.10 in my system):

python -m virtualenv -p python p8

Now I see a directory called p8 being created.

Activating a virtualenv. To activate this virtualenv,

.\p8\Scripts\activate

Now, there is (p8) that precedes the command line prompt, meaning the virtualenv is activated:

(p8) C:\Users\kaiyu\Projects>

Installing pomdp-py

Just running pip install pomdp-py may give error:

  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\kaiyu\Projects\p8\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\kaiyu\\AppData\\Local\\Temp\\pip-install-dihg9eb3\\pomdp-py_461c90125d194435b18594ff90f66b09\\setup.py'"'"'; __file__='"'"'C:\\Users\\kaiyu\\AppData\\Local\\Temp\\pip-install-dihg9eb3\\pomdp-py_461c90125d194435b18594ff90f66b09\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\kaiyu\AppData\Local\Temp\pip-pip-egg-info-as99j__8'
       cwd: C:\Users\kaiyu\AppData\Local\Temp\pip-install-dihg9eb3\pomdp-py_461c90125d194435b18594ff90f66b09\
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\kaiyu\AppData\Local\Temp\pip-install-dihg9eb3\pomdp-py_461c90125d194435b18594ff90f66b09\setup.py", line 5, in <module>
      from Cython.Build import cythonize
  ModuleNotFoundError: No module named 'Cython'

So I did

pip install Cython

and it is installed successfully:

>pip install Cython
Collecting Cython
  Downloading Cython-0.29.24-cp38-cp38-win_amd64.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 3.3 MB/s
Installing collected packages: Cython
Successfully installed Cython-0.29.24

Now, running pip install pomdp-py again... It seems to work!

(p8) C:\Users\kaiyu\Projects>pip install pomdp-py
Collecting pomdp-py
  Using cached pomdp-py-1.3.0.1.tar.gz (109 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: Cython in c:\users\kaiyu\projects\p8\lib\site-packages (from pomdp-py) (0.29.24)
Collecting numpy
  Downloading numpy-1.21.3-cp38-cp38-win_amd64.whl (14.0 MB)
     |████████████████████████████████| 14.0 MB 3.3 MB/s
Collecting scipy
  Downloading scipy-1.7.1-cp38-cp38-win_amd64.whl (33.7 MB)
     |████████████████████████████████| 33.7 MB 3.3 MB/s
Collecting tqdm
  Downloading tqdm-4.62.3-py2.py3-none-any.whl (76 kB)
     |████████████████████████████████| 76 kB 2.4 MB/s
Collecting matplotlib
  Downloading matplotlib-3.4.3-cp38-cp38-win_amd64.whl (7.1 MB)
     |████████████████████████████████| 7.1 MB 6.4 MB/s
Collecting pygame
  Downloading pygame-2.0.3-cp38-cp38-win_amd64.whl (4.8 MB)
     |████████████████████████████████| 4.8 MB 3.3 MB/s
Collecting opencv-python
  Downloading opencv_python-4.5.4.58-cp38-cp38-win_amd64.whl (35.1 MB)
     |████████████████████████████████| 35.1 MB 3.3 MB/s
Collecting cycler>=0.10
  Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting pyparsing>=2.2.1
  Downloading pyparsing-3.0.4-py3-none-any.whl (96 kB)
     |████████████████████████████████| 96 kB 6.4 MB/s
Collecting pillow>=6.2.0
  Downloading Pillow-8.4.0-cp38-cp38-win_amd64.whl (3.2 MB)
     |████████████████████████████████| 3.2 MB 3.2 MB/s
Collecting python-dateutil>=2.7
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 6.4 MB/s
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.3.2-cp38-cp38-win_amd64.whl (52 kB)
     |████████████████████████████████| 52 kB 3.8 MB/s
Collecting colorama
  Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting six>=1.5
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: pomdp-py
  Building wheel for pomdp-py (setup.py) ... done
  Created wheel for pomdp-py: filename=pomdp_py-1.3.0.1-cp38-cp38-win_amd64.whl size=796750 sha256=9ec49b47b3866d5f8ebe40fd142cef54c1ad3b0e0bf87e4a087184a0b285628d
  Stored in directory: c:\users\kaiyu\appdata\local\pip\cache\wheels\67\2b\96\0e9452bfa827d141d12ac3e8ad53f44020bbec1cac8d459249
Successfully built pomdp-py
Installing collected packages: six, python-dateutil, pyparsing, pillow, numpy, kiwisolver, cycler, colorama, tqdm, scipy, pygame, opencv-python, matplotlib, pomdp-py
Successfully installed colorama-0.4.4 cycler-0.11.0 kiwisolver-1.3.2 matplotlib-3.4.3 numpy-1.21.3 opencv-python-4.5.4.58 pillow-8.4.0 pomdp-py-1.3.0.1 pygame-2.0.3 pyparsing-3.0.4 python-dateutil-2.8.2 scipy-1.7.1 six-1.16.0 tqdm-4.62.3

This does work!

python -m pomdp_py -r tiger

pomdp_py_Windows1

The pygame domain also works (it's just the screen seems frozen sometimes):

python -m pomdp_py -r mos

pomdp_py_Windows2