這種新增python path環境變數的方式,只在當前指令碼程式範圍內起作用。若要在整個linux環境中起作用,就要新增設定linux的pythonpath變數。
jxj@ubuntu1
:~/tffrcnn
$ python
python
2.7.12 (default, nov
192016, 06:48
:10)
[gcc
5.4.0
20160609] on linux2
type
or"license"
for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/pilcompat']
>>> sys.path.insert(0, '/home/jxj/tffrcnn')
>>> sys.path
['/home/jxj/tffrcnn', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/pilcompat']
>>> quit()
jxj@ubuntu1
:~/tffrcnn
$ jxj@ubuntu1
:~/tffrcnn
$ python
python
2.7.12 (default, nov
192016, 06:48
:10)
[gcc
5.4.0
20160609] on linux2
type
or"license"
for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/pilcompat']
jxj@ubuntu1
:~/tffrcnn
$ export pythonpath="/home/jxj/tffrcnn:$pythonpath"
jxj@ubuntu1
:~/tffrcnn
$ echo $pythonpath
/home/jxj/tffrcnn
:jxj@ubuntu1
:~/tffrcnn
$ python
python
2.7.12 (default, nov
192016, 06:48
:10)
[gcc
5.4.0
20160609] on linux2
type
or"license"
for more information.
>>> import sys
>>> sys.path
['', '/home/jxj/tffrcnn', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/pilcompat']
>>> quit()
當終端關閉後,該環境變數也會失效。若要每次開啟終端環境都能有效,將export pythonpath=」/home/jxj/tffrcnn:$pythonpath」 新增至 ~/.bashrc 最後即可。
jxj@ubuntu1
:~$ nl .bashrc | tail
87# enable programmable completion features (you don't need to enable
88# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
89# sources /etc/bash.bashrc).
90if ! shopt -oq posix; then
91if [ -f /usr/share/bash-completion/bash_completion ]; then
92 . /usr/share/bash-completion/bash_completion
93 elif [ -f /etc/bash_completion ]; then
94 . /etc/bash_completion
95 fi
96 fi
jxj@ubuntu1
:~$
jxj@ubuntu1
:~$ vim .bashrc
jxj@ubuntu1
:~$
jxj@ubuntu1
:~$ nl .bashrc | tail
89# sources /etc/bash.bashrc).
90if ! shopt -oq posix; then
91if [ -f /usr/share/bash-completion/bash_completion ]; then
92 . /usr/share/bash-completion/bash_completion
93 elif [ -f /etc/bash_completion ]; then
94 . /etc/bash_completion
95 fi
96 fi
97 export pythonpath="/home/jxj/tffrcnn:$pythonpath"
jxj@ubuntu1
:~$ source .bashrc
linux環境下安裝Python3 環境變數配置
安裝依賴包 在安裝python之前需要先安裝依賴包 yum install gcc patch yum install libffi devel yum install python devel yum install zlib devel yum install bzip2 devel yum i...
python中的判斷 python中判斷變數的型別
python中判斷變數的型別 python的資料型別有 數字 int 浮點 float 字串 str 列表 list 元組 tuple 字典 dict 集合 set 一般通過以下方法進行判斷 1 isinstance 引數1,引數2 描述 該函式用來判斷乙個變數 引數1 是否是已知的變數型別 引數2...
ServerVariables集合環境變數列表
語法 request.servervariables server environment variable 引數伺服器環境變數,指定要檢索的伺服器環境變數名。可以使用下面列出的值 變數說明path info轉換後的版本,該變數獲取路徑並進行必要的由虛擬至物理的對映。query string查詢ht...