Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #1

Open
RichardWarfield opened this issue Apr 23, 2019 · 4 comments
Open

Windows support #1

RichardWarfield opened this issue Apr 23, 2019 · 4 comments

Comments

@RichardWarfield
Copy link
Collaborator

Taken from Reddit thread

I'm trying to install this on Windows, but can't get it to work. Before building it turned out I needed to do stack exec -- pacman -S mingw64/mingw-w64-x86_64-zeromq mingw64/mingw-w64-x86_64-python3-pyzmq. Once I built it, I ran it using stack exec ptghci (I had to use stack exec to get it to recognise stack's installation of zmq), but then I get this error:

C:\Users\bradn>stack exec ptghci
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
**Engine stopping**
Fatal Python error: initfsencoding: unable to load the file system codec
Traceback (most recent call last):
File "<frozen importlib._bootstrap_external>", line 1219, in _path_importer_cache
KeyError: 'C:\\Users\\bradn\\Documents\\Haskell\\ptghci\\.stack-work\\install\\fd0322d0\\share\\x86_64-windows-ghc-8.6.4\\ptghci-0.1.0.0\\pybits'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 906, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1280, in find_spec
File "<frozen importlib._bootstrap_external>", line 1249, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1221, in _path_importer_cache
File "<frozen importlib._bootstrap_external>", line 1197, in _path_hooks
File "<frozen importlib._bootstrap_external>", line 1447, in path_hook_for_FileFinder
File "<frozen importlib._bootstrap_external>", line 102, in _path_isdir
File "<frozen importlib._bootstrap_external>", line 87, in _path_is_mode_type
File "<frozen importlib._bootstrap_external>", line 81, in _path_stat
EOFError: Thrown from Haskell

What's happening here?

@bradrn
Copy link

bradrn commented Apr 23, 2019

For reference: I'm the person who originally reported this.

I do have another comment which I forgot to put in the report above: when I do set a value for %PYTHONHOME% (as suggested in the error log), using SET PYTHONHOME=C:\Program Files\Python36, it gave a different error:

C:\Users\bradn>SET PYTHONHOME=C:\Program Files\Python36

C:\Users\bradn>stack exec ptghci
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000a3c0 (most recent call fir**Engine stopping**
st):

(Yes, that's the whole thing, it really did end with a colon)

I suspect though that this is because I may be using the wrong Python installation; possibly I should be using the one in stack's MSYS, since that's where I installed the ZMQ bindings. I wouldn't know what to set it to though; Python is simply in /mingw64/bin/ (or the Windows version, C:\Users\bradn\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\bin\), and I'm not even really sure what PYTHONHOME is supposed to represent.

@RichardWarfield
Copy link
Collaborator Author

Thanks for trying it out and reporting back. I think I've made some progress addressing the issue you raised (though there are some other issues).

First, I've made some updates to the repository, so go ahead and pull those.

Next, you'll need to install python 3, ZeroMQ, pip, and libpcre into Stack's MSYS environment (I guess you've already done this part, but for posterity):

stack exec -- pacman -Sy
stack exec -- pacman -S mingw64/mingw-w64-x86_64-python3 mingw64/mingw-w64-x86_64-zeromq mingw64/mingw-w64-x86_64-python3-pyzmq mingw64/mingw-w64-x86_64-python3-pip mingw64/mingw-w64-x86_64-libpcre
stack exec -- pip3 install -r pybits\requirements.txt

Next, build with stack install.

Finally, to run the program, I had to set PYTHONHOME as follows:

stack exec -- env PYTHONHOME="%USERPROFILE%/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/" ptghci

If that path doesn't work for you, you should be able to figure out the correct path by doing something like stack exec -- python3 -c "import encodings; print(encodings.__file__)". PYTHONHOME should be set to the part before lib.

Another issue on Windows is that the Alt-Enter keyboard combination seems to the CMD window to full-screen mode. You can get around this by using something like Conemu and disabling the hotkey (see here), but then pressing Alt-Enter seems to be create an \ESC in the input that causes errors. I probably need to evaluate a different keyboard combo for Windows users.

@bradrn
Copy link

bradrn commented Apr 23, 2019

Still doesn't work. The error message has gotten a bit shorter, which I suppose is a good sign, but it's still there:

C:\Users\bradn>stack exec -- python3 -c "import encodings; print(encodings.__file__)"
C:/Users/bradn/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/lib/python3.7/encodings/__init__.py

C:\Users\bradn>stack exec -- env PYTHONHOME="C:/Users/bradn/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/" ptghci
**Engine stopping**
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
  File "C:/Users/bradn/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/lib/python3.7\site.py", line 73, in <module>
    import os
  File "C:/Users/bradn/AppData/Local/Programs/stack/x86_64-windows/msys2-20150512/mingw64/lib/python3.7\os.py", line 661, in <module>
    from _collections_abc import MutableMapping
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 818, in get_code
  File "<frozen importlib._bootstrap_external>", line 916, in get_data

@sohang3112
Copy link

Not directly related to your issue - but on Windows, it is a lot easier to install ptghci via WSL (or another Linux virtual environment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants