前言
今天調(diào)annacond3 是, 可能是環(huán)境出了問題
[root@myecsid ~]# python
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/usr/lib64/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Current thread 0x00007f2054b04740 (most recent call first):
Aborted
嘗試
重新配了下環(huán)境變量 path 清回默認(rèn), 為 Anaconda3添加
try01
#echo 'export PATH="/root/anaconda3/bin:$PATH"' >> ~/.bashrc
#source ~/.bashrc
[root@ ~]# unset PYTHONHOME
[root@ ~]# unset PYTHONPATH
python 依舊失敗
[root@ ~]# python
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f62cb4f1740 (most recent call first):
Aborted
但conda 啟動正常
[root@myecsid ~]# conda --version
conda 4.3.30
[root@myecsid ~]# conda env list
# conda environments:
#
python27 /root/anaconda3/envs/python27
root * /root/anaconda3
[root@myecsid ~]# source activate
(root) [root@myecsid ~]# python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
既然 conda 能正常運(yùn)行python , 那證明是可以的,
可能是某些環(huán)境變量變更沒有生效, 導(dǎo)致多版本沖突
還是重啟下服務(wù)器
[root@myecsid ~]# $PATH
-bash: /root/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory
[root@myecsid ~]# python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
果然如此 解決