2013-10-31 14 views
11

से अलग पिचर्म पर्यावरण अलग-अलग मुझे अपने पिचर्म पर्यावरण को कमांड लाइन पर पर्यावरण के साथ मेल खाने में कोई समस्या हो रही है। मैंने हाल ही में अजगर को हटा दिया और इसे होम ब्रू के माध्यम से पुनः स्थापित किया। मेरे पथ में पाइथन /usr/local/bin/python पर इंगित कर रहा है मैंने अपनी .bash_profile फ़ाइल की शुरुआत में PATH=/usr/local/bin:$PATH जोड़ा और मैं कमांड लाइन पर इंटरपरटर में बस निम्न कोड निष्पादित कर सकता हूं। हालांकि, जब मैं प्रोजेक्ट पायथन दुभाषियों को /usr/local/bin/python जोड़ता हूं और नीचे कोड चलाता हूं तो मुझे विशेषता त्रुटि मिलती है। क्या कोई भी मेरी कमांड लाइन के समान वातावरण का उपयोग करने के लिए पिचर्म को कैसे प्राप्त कर सकता है इस पर कुछ प्रकाश डाल सकता है?कमांड लाइन

import sqlite3 
db = "mydb.db" 
conn = sqlite3.connect(db) 
conn.enable_load_extension(True) 

AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'

+2

के संदर्भ में @Federicojama से http://stackoverflow.com/q/135688/104891 देखें। जीयूआई ऐप्स आपके '.bash_profile' को नहीं पढ़ते हैं। – CrazyCoder

+0

ugh ... ऐसा लगता है कि ओएस एक्स के प्रत्येक संस्करण को यह अलग-अलग संभालता है ... – CLJ

उत्तर

15

.bash_profile केवल बैश (अपने कमांड लाइन दुभाषिया) द्वारा पढ़ा जा रहा है। हालांकि यदि आप PyCharm के लिए बैश वातावरण को संरक्षित करना चाहते हैं तो एक सही लिनक्स तरीका है।

अपनी कमांड लाइन (बैश से) से PyCharm चलाएं। इस प्रकार पर्यावरण चर को बैश से पिचर्म तक विरासत में मिलाया जाएगा। लिनक्स पर्यावरण विरासत प्रक्रिया के बारे में जानकारी के लिए $man पर्यावरण पढ़ें। तो आपको केवल कमांड लाइन से ${PATH_TO_PYCHARM}/bin/pycharm.sh लॉन्च करना है। या लॉन्चर बनाएं जो PyCharm लॉन्चिंग के लिए बैश को आमंत्रित करता है।

यह बात है! उम्मीद है वह आप के काम आएगा।

2

एक और दृष्टिकोण PY_CHARM_INSTALL_DIR/bin/pycharm.sh में एक लाइन . /path/to/script जोड़कर अपनी स्क्रिप्ट (उदाहरण के .bash_profile के लिए) पर्यावरण चर की स्थापना स्रोत है।

इसके बाद आप जल्दी-दोपहर का उपयोग करके पिचर्म चला सकते हैं या जो भी और आप चर होंगे।

1

दुर्भाग्यवश मैक ओएस एक्स में, ग्राफ़िक एप्लिकेशन आपके .bash_profile कॉन्फ़िगरेशन का वारिस नहीं करते हैं। मैं OSX के लिए 10.11 अद्यतन वैकल्पिक हल पोस्टिंग कर रहा हूँ कैसे जीयूआई स्तर पर वातावरण चर को सेट करने के:

osx-env-sync नामक एक उपयोगी रेपो जो ~/.bash_profile पढ़ता है और जीयूआई अनुप्रयोगों के लिए उस में निर्यात वातावरण चर सेट नहीं है। 2 फाइलों की प्रतिलिपि बनाने और गिटूब पेज पर वर्णित 2 अन्य आदेशों को चलाने के बाद, पिचर्म को bash_profile में परिभाषित वैश्विक चर के साथ त्वरित शुरुआत में लॉन्च किया जा सकता है।

This लिंक आगे पृष्ठभूमि जानकारी देता है।

3

आप PyCharm संस्करण 2016.3 उपयोग कर रहे हैं और देखा है कि आपका PyCharm टर्मिनल अब अपने MacOS टर्मिनल वातावरण के रूप में एक ही डिफ़ॉल्ट वातावरण प्रदान कर रहा है, तो यह एक bug कि 2016/03/01 में तय किया जाना चाहिए है - जब भी यह रिलीज करता है।

निम्नलिखित सामग्री के साथ एक ~/.bashrc फ़ाइल बनाएँ: इस बीच, निम्नलिखित एक समाधान है कि 'डिफ़ॉल्ट' अपने PyCharm परियोजनाओं के सभी वापस एक और अधिक अधिक MacOS-टर्मिनल PyCharm-टर्मिनल की तरह करना चाहिए source /etc/bashrc source /etc/bashrc_Apple_Terminal source ~/.bash_profile

यह चाहिए सेटअप अपने PyCharm टर्मिनल (इंटरैक्टिव बैश सत्र) है और यह MacOS टर्मिनल (लॉगिन बैश सत्र) के समान हैं।एक बार JetBrains 2016.3.1 को पैच और रिलीज़ करने के बाद, मैं इस ~/.bashrc फ़ाइल को हटाने की अनुशंसा करता हूं। उम्मीद है कि यह हमें सामान्य रूप से वापस ले जाएगा।

+1

दुर्भाग्यवश, यह बग अभी भी 2017.1.2 के रूप में मौजूद है –

1

संपादित करें: स्पष्ट करने के लिए PyCharm 2016.3.0

यह वास्तव में अनुशंसा की जाती है कि आप बस 2016/03/01 जब तक प्रत्येक टर्मिनल सत्र के प्रारंभ में निम्न आदेश

source ~/.bash_profile 

चलाने इस समाधान है कि प्रकाशित हो चूका।

हालांकि, इस बग के लिए एक कामकाज है। प्रतीत होता है कि टर्मिनल स्क्रिप्ट में 2 फ़ंक्शन नाम उलट दिए गए हैं, इसलिए उनका नाम बदला जाना चाहिए।

ऐसा करने के लिए आपको ऐप की टर्मिनल प्लगइन स्क्रिप्ट को संपादित करना होगा, जिसकी अनुशंसा नहीं की जाती है।

MacOSX पर, यह यहाँ (यकीन नहीं जहां अन्यथा) स्थित है, तो PyCharm विश्व स्तर पर स्थापित किया गया है:

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

संपादित करें 'jediterm-bash.in' अपनी पसंद का पाठ प्रोसेसर के साथ फ़ाइल। तो इस तरह दिखना चाहिए:

#!/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 

निम्नलिखित कार्य का नाम बदलें:

load_login_configs =>load_interactive_configs

load_interactive_configs =>load_login_configs

अंतिम स्क्रिप्ट होना चाहिए:

#!/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 

PyCharm को सहेजें और पुनरारंभ करें और आपको जाने के लिए अच्छा होना चाहिए।

0

मेरे लिए क्या अनुप्रयोगों से पिचर्म नहीं चल रहा था लेकिन क्रोम का उपयोग कर टर्मिनल से काम नहीं कर रहा था। तो यह सब env वार्स और रास्तों

0

मैं वास्तव में सिर्फ यह है कि

अचिह्नित PyCharm 2017/01/02 में काम करता है उपकरण> टर्मिनल> "शेल एकीकरण"

के लिए एक समाधान पाया विरासत में मिला स्रोत: इस सवाल का जवाब पेज https://intellij-support.jetbrains.com/hc/en-us/community/posts/208567485-Pycharm-terminal-is-missing-part-of-PATH