推荐学习书目
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
ingin
V2EX  ›  Python

Python 环境变量问题

  •  
  •   ingin · Jul 19, 2018 · 2813 views
    This topic created in 2943 days ago, the information mentioned may be changed or developed.
    print(os.environ.get("V2EX"))

    用 pycharm 直接运行无法获取到系统的环境变量, 但是用终端直接 python 文件名,是可以获取到的,崩溃! 有大神知道原因吗,跪谢!

    9 replies    2018-07-21 13:34:10 +08:00
    mikeguan
        1
    mikeguan  
       Jul 19, 2018 via Android
    这不是 python 环境变量 这是系统环境变量 确认系统里面的环境变量是全局的吗?
    ingin
        2
    ingin  
    OP
       Jul 19, 2018 via Android
    @mikeguan 是全局的,只有用 pycharm 右键运行打印不出来,可怕的是项目运行时有时能获取有时又不能!
    hzwjz
        3
    hzwjz  
       Jul 19, 2018 via Android
    碰到这个事情,之前是在那个下拉选配置的里面设置了就好了。
    ingin
        4
    ingin  
    OP
       Jul 19, 2018 via Android
    @hzwjz 能仔细说下吗
    Hieast
        5
    Hieast  
       Jul 19, 2018
    系统环境变量在你创建 Run 任务的时候就固定到 Run 配置的环境中了
    rrfeng
        6
    rrfeng  
       Jul 19, 2018
    环境变量的环境是指

    一个进程运行的环境。
    xuegj1010
        7
    xuegj1010  
       Jul 19, 2018
    File>>Settings>>Project:xxx>>Project Interpreter
    在 Project Interpreter 找到你系统中 python 的位置,或者创建一个虚拟环境
    nature91
        8
    nature91  
       Jul 20, 2018
    我是这样的 每个项目确保环境独立 单独建个虚拟环境 路径配到 python (各种版本可能)配的 保持唯一
    careofzm
        9
    careofzm  
       Jul 21, 2018
    你可以在 configure 中 environment variables 中设置环境变量
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5096 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 124ms · UTC 01:16 · PVG 09:16 · LAX 18:16 · JFK 21:16
    ♥ Do have faith in what you're doing.