Pycharm environment different than command line

后端 未结 7 1340
轮回少年
轮回少年 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 11:17

    Edit: clarifying that this workaround is for PyCharm 2016.3.0

    It's really recommended that you just run the following command

    source ~/.bash_profile
    

    at the start of each terminal session until 2016.3.1 is released.

    However, there is a workaround for this bug. The terminal script appears to have 2 function names reversed, so they must be renamed.

    You have to edit the app's terminal plugin script to do this, which is NOT recommended.

    On MacOSX, this is located here if PyCharm is installed globally (not sure where otherwise):

    cd /Applications/PyCharm.app/Contents/plugins/terminal
    

    Edit the 'jediterm-bash.in' file with the text processor of your choice. If should look like this:

    #!/bin/bash
    
    function load_login_configs {
      #       When bash is invoked as an interactive login shell, or as a  non-interac-
      #       tive  shell with the --login option, it first reads and executes commands
      #       from the file /etc/profile, if that  file  exists.   After  reading  that
      #       file,  it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in
      #       that order, and reads and executes  commands  from  the  first  one  that
      #       exists  and  is  readable.
    
      if [ -f /etc/profile ]; then
         source /etc/profile
      fi
    
      if [ -f ~/.bash_profile ]; then
         source ~/.bash_profile
      else
         if [ -f ~/.bash_login ]; then
            source ~/.bash_login
         else
            if [ -f ~/.profile ]; then
               source ~/.profile
            fi
         fi
      fi
    }
    
    function load_interactive_configs {
      if [ -f ~/.bashrc ]; then
           source ~/.bashrc
      fi
    }
    
    if [ `shopt -q login_shell` ]; then
      load_login_configs
    fi
    
    load_interactive_configs
    
    # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
    bind '"\e\e[C":forward-word'
    bind '"\e\e[D": backward-word'
    bind '"\e\O[C":forward-word'
    bind '"\e\O[D": backward-word'
    
    function generate_command_executed_sequence() {
       printf '\e\7'
    }
    
    export -f generate_command_executed_sequence
    
    
    #generate escape sequence after command is executed to notify jediterm emulator
    trap "generate_command_executed_sequence" DEBUG
    
    if [ -n "$JEDITERM_USER_RCFILE" ]
    then
      source $JEDITERM_USER_RCFILE
    fi
    
    if [ -n "$JEDITERM_SOURCE" ]
    then
      source $JEDITERM_SOURCE
    fi
    

    Rename the following functions:

    load_login_configs => load_interactive_configs

    load_interactive_configs => load_login_configs

    The final script should be:

    #!/bin/bash
    
    function load_interactive_configs {
      #       When bash is invoked as an interactive login shell, or as a  non-interac-
      #       tive  shell with the --login option, it first reads and executes commands
      #       from the file /etc/profile, if that  file  exists.   After  reading  that
      #       file,  it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in
      #       that order, and reads and executes  commands  from  the  first  one  that
      #       exists  and  is  readable.
    
      if [ -f /etc/profile ]; then
         source /etc/profile
      fi
    
      if [ -f ~/.bash_profile ]; then
         source ~/.bash_profile
      else
         if [ -f ~/.bash_login ]; then
            source ~/.bash_login
         else
            if [ -f ~/.profile ]; then
               source ~/.profile
            fi
         fi
      fi
    }
    
    function load_login_configs {
      if [ -f ~/.bashrc ]; then
           source ~/.bashrc
      fi
    }
    
    if [ `shopt -q login_shell` ]; then
      load_login_configs
    fi
    
    load_interactive_configs
    
    # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
    bind '"\e\e[C":forward-word'
    bind '"\e\e[D": backward-word'
    bind '"\e\O[C":forward-word'
    bind '"\e\O[D": backward-word'
    
    function generate_command_executed_sequence() {
       printf '\e\7'
    }
    
    export -f generate_command_executed_sequence
    
    
    #generate escape sequence after command is executed to notify jediterm emulator
    trap "generate_command_executed_sequence" DEBUG
    
    if [ -n "$JEDITERM_USER_RCFILE" ]
    then
      source $JEDITERM_USER_RCFILE
    fi
    
    if [ -n "$JEDITERM_SOURCE" ]
    then
      source $JEDITERM_SOURCE
    fi
    

    Save and restart PyCharm and you should be good to go.

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