推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
jin7
V2EX  ›  Python

太难受了, 求助, pycharm 的 terminal 突然不能自动激活 venv 了

  •  
  •   jin7 · Jan 16, 2020 · 4364 views
    This topic created in 2308 days ago, the information mentioned may be changed or developed.
    求助, pycharm 的 terminal 突然不能激活 venv 了
    pycharm 2019.3.1
    windows 10 版本 10.0.18363.592
    powershell.exe 5.1.18362.145
    terminal shell 是 powershell.exe 之前一直正常的, 突然不正常了.
    项目路径没有任何中文和特殊符号.
    谷歌了几个帖子也没发现什么解决方案.
    https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003647920-Pycharm-Terminal-fails-to-activate-virtual-env
    https://youtrack.jetbrains.com/issue/PY-22469
    terminal shell 改成 cmd.exe 是正常的.
    10 replies    2020-07-26 09:04:42 +08:00
    jin7
        1
    jin7  
    OP
       Jan 16, 2020
    执行 Get-Command python.exe
    发现 python.exe 确实在 venv 下面, 但是命令提示符前面那个(venv)没有出现, 之前都是有的, 我再测试下.
    jin7
        2
    jin7  
    OP
       Jan 17, 2020
    可能是我的错觉吧.
    用别人电脑全新安装了 pycharm 然后设置 terminal shell 为 powershell , 结果和上面一样.
    nzbst
        3
    nzbst  
       Jan 17, 2020
    File-->Settings-->Project-->Project Interpreter-->Project Interpreter 下拉-->Show All,
    然后选择你的虚拟环境, 如果没有的话, 新建一个.
    no1xsyzy
        4
    no1xsyzy  
       Jan 17, 2020
    ```powershell
    pip -V
    $env:VIRTUAL_ENV
    $env:PATH
    ```

    都看看是哪,如果都正常指向 venv 内的话,看下这个的值
    ```powershell
    (Get-Command prompt).ScriptBlock
    ```
    no1xsyzy
        5
    no1xsyzy  
       Jan 17, 2020
    只要上面三个指向了,venv 就应该已经启动了
    但 prompt 没有加载的原因不清楚,大概需要排查下 activate.ps1
    jin7
        6
    jin7  
    OP
       Jan 17, 2020
    @nzbst 谢谢回复 这个是配置好了的. 只是命令提示符前面那个(venv)没有出现, 导致我以为 venv 没有被激活.
    (venv) PS C:\Users\jin7>
    jin7
        7
    jin7  
    OP
       Jan 17, 2020
    @no1xsyzy 谢谢 这个都指向正常. venv 确实启动了
    手动执行 .\venv\Scripts\Activate.ps1 才会出现(venv)
    hushao
        8
    hushao  
       Jan 18, 2020 via iPhone
    3 楼正解
    rizon
        9
    rizon  
       Jul 25, 2020
    查了半天 查到这个帖了。。。楼主你解决这个问题了吗。。。它激活脚本好像用了 bat 的脚本 而不是 ps1 的 真难受
    jin7
        10
    jin7  
    OP
       Jul 26, 2020
    @rizon #9 用 cmd 好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1199 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:23 · PVG 07:23 · LAX 16:23 · JFK 19:23
    ♥ Do have faith in what you're doing.