Pycharm environment different than command line

后端 未结 7 1339
轮回少年
轮回少年 2020-12-05 10:11

I am having an issue getting my Pycharm environment to match up with the environment that I have on the command line. I recently removed python and reinstalled it via home

相关标签:
7条回答
  • 2020-12-05 10:53

    I actually just found a solution for this that works in PyCharm 2017.1.2

    uncheck Tools > Terminal > "shell integration"

    source: answer from @Federicojama near the bottom of the page https://intellij-support.jetbrains.com/hc/en-us/community/posts/208567485-Pycharm-terminal-is-missing-part-of-PATH

    0 讨论(0)
  • 2020-12-05 10:55

    Unfortunately in Mac OS X, graphic applications do not inherit your .bash_profile config. I'm posting the updated workaround for OSX 10.11 on how to set up environment variables at GUI level:

    There is a useful repo called osx-env-sync which reads ~/.bash_profile and sets the environment variables exported in it for GUI applications. After copying 2 files and running 2 other commands described on the github page, Pycharm can be launched in quick-start with global variables available as defined in the bash_profile.

    This link gives further background information.

    0 讨论(0)
  • 2020-12-05 10:56

    for me what worked was not running pycharm from the applications but from a terminal using chram . then it inherited all the env vars and paths

    0 讨论(0)
  • 2020-12-05 11:04

    Another approach is to source your script setting environmental variables (for example .bash_profile) by adding a line . /path/to/script into PY_CHARM_INSTALL_DIR/bin/pycharm.sh.

    After that you can run pycharm using quick-lunch or whatever and you variables will be there.

    0 讨论(0)
  • 2020-12-05 11:07

    If you are using PyCharm version 2016.3 and have noticed that your PyCharm Terminal is no longer providing the same default environment as your MacOs Terminal environment, it is a bug that should be fixed in 2016.3.1 - whenever it releases. In the mean time, the following is a workaround that should 'default' all of your PyCharm projects back a more more MacOS-Terminal like PyCharm-Terminal:

    Create a ~/.bashrc file with the following contents: source /etc/bashrc source /etc/bashrc_Apple_Terminal source ~/.bash_profile

    This should setup your PyCharm Terminal (interactive bash session) and make it similar to the MacOS Terminal (login bash session). Once JetBrains patches and releases 2016.3.1, I recommend deleting this ~/.bashrc file. Hopefully this will get us all back to normal.

    0 讨论(0)
  • 2020-12-05 11:12

    .bash_profile is being read by bash (your command line interpreter) only. However if you want to preserve bash environment for PyCharm there is one true Linux way.

    Run PyCharm from your command line (from bash). Thus environment variables will be inherited from bash to pycharm. Read $man environ for information on linux environment inheritance process. So all you need is just launch ${PATH_TO_PYCHARM}/bin/pycharm.sh from command line. Or create launcher which invokes bash for PyCharm launching.

    Thats it ! Hope that works for you.

    0 讨论(0)
提交回复
热议问题