8000 import error on Windows, no "HOME" environment variable · Issue #148 · zdict/zdict · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

import error on Windows, no "HOME" environment variable #148

Closed
bnn00023 opened this issue Dec 7, 2017 · 14 comments
Closed

import error on Windows, no "HOME" environment variable #148

bnn00023 opened this issue Dec 7, 2017 · 14 comments
Assignees

Comments

@bnn00023
Copy link
bnn00023 commented Dec 7, 2017

Hi zdict:
I feel this is good stuff,I want use it.First I install it.And I use my Python3.6 import zdict,that issue error.
My operating is wrong? Sorry my English is not well.

Traceback (most recent call last):
  File "D:/Algorithm/test.py", line 1, in <module>
    import zdict.zdict
  File "C:\Users\E17012\AppData\Local\Programs\Python\Python36-32\lib\site-packages\zdict\__init__.py", line 1, in <module>
    from zdict import utils
  File "C:\Users\E17012\AppData\Local\Programs\Python\Python36-32\lib\site-packages\zdict\utils.py", line 4, in <module>
    from zdict import constants
  File "C:\Users\E17012\AppData\Local\Programs\Python\Python36-32\lib\site-packages\zdict\constants.py", line 7, in <module>
    BASE_DIR = os.path.join(os.getenv('HOME'), BASE_DIR_NAME)
  File "C:\Users\E17012\AppData\Local\Programs\Python\Python36-32\lib\ntpath.py", line 75, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
@fkztw fkztw added the bug label Dec 7, 2017
@fkztw fkztw self-assigned this Dec 7, 2017
@fkztw
Copy link
Member
fkztw commented Dec 7, 2017

@bnn00023 os.getenv('HOME') return None caused this error.

I think it's because you are using Windows and we don't have any testings for Windows platform. Honestly, this is a side project and none of developers of this project using zdict on Windows. See these two lines in setup.py? No Windows.

But, we will be glad to see zdict work on Windows, so I will try to fix this bug. Yet, I don't think zdict will work on Windows just after I solve this bug. (If it does, it would be great. Just let you know first.)

It would be great if you can help us test zdict on Windows platform. =)

fkztw pushed a commit that referenced this issue Dec 7, 2017
Use `os.path.expanduser` instead of using `os.path.join` directly,
since the formmer is better handled for Windows.

ref: <https://docs.python.org/3/library/os.path.html#os.path.expanduser>
@wdv4758h wdv4758h changed the title import error import error on Windows, no "HOME" environment variable Dec 8, 2017
@bnn00023
Copy link
Author

Thank your answer,and my platform is windows 7. If need my test on W7 or W10,it is my pleasure.

@fkztw
Copy link
Member
fkztw commented Dec 12, 2017

@bnn00023 I'm wondering if you can use zdict with docker on Windows 7 or Windows 10. Could you give it a try?

@bnn00023
Copy link
Author
bnn00023 commented Dec 13, 2017

Yes I can. But... I never use docker. I will learn it. Give me some time.

@bnn00023
Copy link
Author

this is on Windows 7

E17012@prodser MINGW64 ~
$ zdict
Traceback (most recent call last):
File "C:/Users/E17012/AppData/Local/Programs/Python/Python36-32/Scripts/zdict"
, line 3, in
from zdict import zdict
File "C:\users\e17012\appdata\local\programs\python\python36-32\lib\site-packa
ges\zdict_init_.py", line 1, in
from zdict import utils
File "C:\users\e17012\appdata\local\programs\python\python36-32\lib\site-packa
ges\zdict\utils.py", line 99, in
readline = import_readline()
File "C:\users\e17012\appdata\local\programs\python\python36-32\lib\site-packa
ges\zdict\utils.py", line 95, in import_readline
import readline
ModuleNotFoundError: No module named 'readline'

I try search "readline" want know what's happen , but I lost it...

I don't know my operating is right or wrong. if it's wrong .Please tell me.

@wdv4758h
Copy link
Member

I don't think CPython has builtin readline support on Windows.

There is a pure Python implementation called pyreadline for Windows, but it isn't updated for 2 years. The pyreadline was developed by IPython community as gnureadline replacement for Windows, but they removed both pyreadline and gnureadline dependencies in favor of prompt-toolkit now.

@wdv4758h
Copy link
Member

Actually, I have a opening issue for prompt-toolkit support, but I've never spent time on it :P

Uh oh!

There was an error while loading. Please reload this page.

@wdv4758h
Copy link
Member

We probably are able to run on the Windows Subsystem for Linux though, but I don't have any enviroment to test.

@bnn00023
Copy link
Author

@wdv4758h
Hi,wdv4758h
I install prompt-toolkit support and import it. It show error message. And I see

Runs on all Python versions from 2.6 up to 3.5.

In Python Prompt Toolkit\README.rst.

Should I use Python 3.5?

@wdv4758h
Copy link
Member

I think prompt-toolkit works fine on CPython 3.6, since I'm using version 3.6 :P

But the problem is zdict does not support prompt-toolkit yet, so it's not a drop-in replacement here.

Let me summarize them:

  • zdict use readline or gnureadline, but Windows doesn't have any of them
  • there is a pyreadline probably can easily fix the problem with very few modification in zdict
  • zdict probably can work on the Windows Subsystem for Linux
  • there is a way can remove readline/gnureadline dependencies, which is use prompt-toolkit for our interactive shell, but it needs more modification in zdict

@bnn00023
Copy link
Author

No module named 'readline' ← The error miss when I install pyreadline after.Now happen new problem.

image

I use docker toolbox with Windows 7.

@bnn00023
Copy link
Author

I can use this!!
image
but... I don't remember what step when I do. maybe useful step is install pyreadline.

this is docker toolbox with Windows 7. I will test on Windows 10 next time.

@fkztw
Copy link
Member
fkztw commented Dec 18, 2017

@bnn00023
The problem in this comment according to your screenshot is:

You did it wrong when you typed export LC_ALL=UTF-8 and export LANG=UTF-8.
You ignored the warning in the first line.
It told you there's no locale named UTF-8.
You can use locale -a to see what encodings you can set.

You can use locale to see your current locale-specific info.
I believe it's something like en_US.UTF-8 or zh_TW.UTF-8.

@bnn00023
Copy link
Author

it's successful on Windows 10 with docker toolbox. I will check what happen on Windows 7. Maybe my procedures is wrong.
image

fkztw pushed a commit that referenced this issue Feb 24, 2018
Use `os.path.expanduser` instead of using `os.path.join` directly,
since the formmer is better handled for Windows.

ref: <https://docs.python.org/3/library/os.path.html#os.path.expanduser>
fkztw pushed a commit that referenced this issue Feb 24, 2018
+ Remove Python 2.
+ Added install part.
fkztw pushed a commit that referenced this issue Feb 24, 2018
Install gnureadline for OSX with Python version <= 3.5.
Install pyreadline for Windows.
fkztw pushed a commit that referenced this issue Feb 24, 2018
No need to use patch for linux, darwin and windows
because we will run test on all these platforms.
fkztw pushed a commit that referenced this issue Feb 24, 2018
@fkztw fkztw closed this as completed Feb 24, 2018
fkztw pushed a commit that referenced this issue Feb 24, 2018
Use `os.path.expanduser` instead of using `os.path.join` directly,
since the formmer is better handled for Windows.

ref: <https://docs.python.org/3/library/os.path.html#os.path.expanduser>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants
0