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

No module named 'termios #7

Closed
zzqq2199 opened this issue Feb 10, 2021 · 5 comments
Closed

No module named 'termios #7

zzqq2199 opened this issue Feb 10, 2021 · 5 comments

Comments

@zzqq2199
Copy link

作者您好!在使用您的软件的时候遇到了如下报错,请问如何解决?万分感谢!

Python version: 3.8.5

Traceback (most recent call last):
  File "c:\users\togo\miniconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\togo\miniconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\togo\miniconda3\Scripts\md2zhihu.exe\__main__.py", line 4, in <module>
  File "c:\users\togo\miniconda3\lib\site-packages\md2zhihu\__init__.py", line 9, in <module>
    from . import md2zhihu
  File "c:\users\togo\miniconda3\lib\site-packages\md2zhihu\md2zhihu\__init__.py", line 8, in <module>
    import k3down2
  File "c:\users\togo\miniconda3\lib\site-packages\k3down2\__init__.py", line 16, in <module>
    from .down2 import convert
  File "c:\users\togo\miniconda3\lib\site-packages\k3down2\down2.py", line 15, in <module>
    import k3proc
  File "c:\users\togo\miniconda3\lib\site-packages\k3proc\__init__.py", line 15, in <module>
    from .proc import CalledProcessError
  File "c:\users\togo\miniconda3\lib\site-packages\k3proc\proc.py", line 8, in <module>
    import pty
  File "c:\users\togo\miniconda3\lib\pty.py", line 12, in <module>
    import tty
  File "c:\users\togo\miniconda3\lib\tty.py", line 5, in <module>
    from termios import *
ModuleNotFoundError: No module named 'termios'
@zzqq2199
Copy link
Author

使用的是Windows操作系统

@drmingdrmer
Copy link
Owner

我看了下termios, tty 和pty都应该是python官方的包, 可能是你的python版本问题, 我的pty位置是在:
'/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pty.py', 可能你自己安装了pty的某个版本导致的问题?

@bug-orz
Copy link

bug-orz commented Feb 19, 2021

我看了下termios, tty 和pty都应该是python官方的包, 可能是你的python版本问题, 我的pty位置是在:
'/usr/local/Cellar/python@3.8/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pty.py', 可能你自己安装了pty的某个版本导致的问题?

win10好像不支持这个包,win10能否使用此工具呢?
https://stackoverflow.com/questions/52062977/unable-to-import-termios-package

Stack Overflow
I am using Python 3.7 and I need to import termios to mask a password input. But I am unable to find it on https://pypi.org/

import sys, tty, termios

Traceback (most recent call last):
File "<

@drmingdrmer
Copy link
Owner

drmingdrmer commented Mar 3, 2021

windows 上没法直接使用, 可以通过github-action实现远程自动转换:

使用 github-action 远程转换, 适合 Windows 用户

md2zhihu 不支持windows, 可以通过github-action来实现远程转换:

  • 首先将要转换的 markdown 全部放在一个 github repo 中, 完成配置后, 每次 push 之后 github-action 将自动构建,
    例如 我自己的博客中的文章都在这个repo中: https://github.com/drmingdrmer/drmingdrmer.github.io

  • 生成 github token, 以授权github action可以将转换的文档 push 回 repo:
    通过以下链接创建:
    https://github.com/settings/tokens/new

    具体步骤参考:
    https://docs.github.com/cn/github/authenticating-to-github/creating-a-personal-access-token

    创建后应该在以下页面看到刚创建的token:
    https://github.com/settings/tokens

  • 将上面生成的token 添加到存储文章的 repo, 名为 GH_TOKEN,
    让 github-action 使用这个 token 来 push 代码:
    在 repo 主页, 通过菜单 setting-Secrets-New repository secret 进入添加token页面.

    例如我博客repo的添加token的在:
    https://github.com/drmingdrmer/drmingdrmer.github.io/settings/secrets/actions

    添加后效果如下:

  • 在文章 repo 中创建 action 描述文件, 定义一个github-action,
    为每次 push 进行转换:
    .github/workflows/md2zhihu.yml, 内容为:

    name: md2zhihu
    on:
      push:
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v2
        - uses: actions/setup-python@v2
          with:
            python-version: 3.8
        - name: Install
          run: |
            git clone https://github.com/drmingdrmer/md2zhihu.git
            sh md2zhihu/github-install.sh
        - name: build zhihu compatible markdowns
          env:
            GITHUB_USERNAME: ${{ github.repository_owner }}
            GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
          run: |
            md2zhihu \
            --repo https://github.com/${{ github.repository }}.git@zhihu_branch \
            --code-width 600 \
            --asset-dir _md2zhihu \
            _posts/*.md

    然后将配置文件 commit 到 repo 中:
    git add .github && git commit -m 'action: md2zhihu'

    用以上配置, 在下一次push时, github action 将目录 _posts/ 中所有的md文件进行转换,
    并保存到zhihu_branch 分支中.

    例如我的博客中文章装换后在:
    https://github.com/drmingdrmer/drmingdrmer.github.io/tree/zhihu_branch/zhihu

  • 要使用转换后的文档, 可以将这个zhihu_branch分支clone下来:

    git clone https://github.com/drmingdrmer/drmingdrmer.github.io -b zhihu_branch

    </drmingdrmer.github.io/zhihu/
    ▾ ansible-import-include/
        ansible-import-include.md
    ▾ cdn/
         1kfile.png
         1kloglog-regression.png
         bigmap.jpg
         cdn-arch.jpg
         cdn.md
         edge-backsource-cost.png
    ▾ cgexec/
        cgexec.md
    

    或直接从github repo 中访问, 例如:
    https://github.com/drmingdrmer/drmingdrmer.github.io/blob/zhihu_branch/zhihu/paxoskv/paxoskv.md

GitHub
my home. Contribute to drmingdrmer/drmingdrmer.github.io development by creating an account on GitHub.
GitHub
GitHub is where people build software. More than 56 million people use GitHub to discover, fork, and contribute to over 100 million projects.
您应该通过命令行或 API 创建个人访问令牌来代替密码。
GitHub
GitHub is where people build software. More than 56 million people use GitHub to discover, fork, and contribute to over 100 million projects.
GitHub
GitHub is where people build software. More than 56 million people use GitHub to discover, fork, and contribute to over 100 million projects.
GitHub
my home. Contribute to drmingdrmer/drmingdrmer.github.io development by creating an account on GitHub.
GitHub
my home. Contribute to drmingdrmer/drmingdrmer.github.io development by creating an account on GitHub.

@zzqq2199
Copy link
Author

zzqq2199 commented Mar 3, 2021

非常感谢作者的热心!

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