1. 程式人生 > >suse上非root使用者安裝python2.7.14與jupyter

suse上非root使用者安裝python2.7.14與jupyter

安裝路徑:/home/user1/mysoft/python2.7.14

安裝python2.7.14 解壓存放路徑:/home/user1/soft/

tar -xvf python2.7.14.tar.gz
./configure --prefix=/home/user1/mysoft/python2.7.14 --enable-shared
make
make install

設定

PYTHONHOME=/home/user1/mysoft/python2.7.14;
export PYTHONHOME
PYTHONPATH=/home/user1/mysoft/python2.7.14/lib;
export PYTHONPATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHONPATH;
export LD_LIBRARY_PATH

安裝 setuptools-40.4.3

解壓setuptools-40.4.3

/home/user1/mysoft/python2.7.14/bin/python setup.py install

安裝pip-18.0

/home/user1/mysoft/python2.7.14/bin/python setup.py install

安裝readline-6.2.4.1.tar.gz 缺少readline module

/home/user1/mysoft/python2.7.14/bin/python setup.py install

安裝jupyter-離線 安裝zeromq-3.2.5

./configure
make
make install  -root使用者

安裝 Cython-0.29 解壓Cython-0.29執行:/home/user1/mysoft/python2.7.14/bin/python setup.py install

安裝pyzmq-master 解壓pyzmq-master執行:/home/user1/mysoft/python2.7.14/bin/python setup.py install

安裝scandir-master 解壓scandir-master執行:/home/user1/mysoft/python2.7.14/bin/python setup.py install

離線安裝jupyter/home/user1/mysoft/python2.7.14/bin/pip install --no-index --find-links=/home/user1/mysoft/soft/jupyter -r request.txt

安裝jupyter之前需要安裝zeromq-3.2.5 pyzmq-master---依賴於zeromq-3.2.5,scandir-master request.txt內容

backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
backports.shutil-which==3.5.1
bleach==3.0.2
colorama==0.4.0
configparser==3.5.0
decorator==4.3.0
defusedxml==0.5.0
entrypoints==0.2.3
enum34==1.1.6
functools32==3.2.3.post2
futures==3.2.0
ipaddress==1.0.22
ipykernel==4.10.0
ipython==5.8.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
Jinja2==2.10
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==5.2.0
jupyter-core==4.4.0
MarkupSafe==1.0
mistune==0.8.4
nbconvert==5.4.0
nbformat==4.4.0
notebook==5.7.0
pandocfilters==1.4.2
pathlib2==2.3.2
pickleshare==0.7.5
prometheus-client==0.4.1
prompt-toolkit==1.0.15
Pygments==2.2.0
python-dateutil==2.7.3
qtconsole==4.4.2
Send2Trash==1.5.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
terminado==0.8.1
testpath==0.4.2
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2
win-unicode-console==0.5

新增環境變數

PATH=/home/user1/mysoft/python2.7.14/bin:$PATH; export PATH

設定語言環境不設定以下內容,會報錯UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 4: ordinal not in range(128) LANG="en_US.UTF-8" export LANG LANGUAGE="en_US:en" export LANGUAGE

遇到的問題

問題1:

from pysqlite2 import dbapi2 as sqlite3 ImportError: No module named pysqlite2

linux系統安裝 sqlite3 sqlite-devel 重新編譯安裝python

問題2:

[email protected]:~/mysoft/soft/Python-2.7.14> jupyter notebook The Jupyter HTML Notebook.     self.print_subcommands()   File "/home/user1/mysoft/python2.7.14/lib/python2.7/site-packages/traitlets/config/application.py", line 377, in print_subcommands     print(os.linesep.join(lines)) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 4: ordinal not in range(128)

解決:

LANG="en_US.UTF-8" export LANG LANGUAGE="en_US:en" export LANGUAGE

python make報錯

gcc -pthread -shared build/temp.linux-i686-2.7/home/user1/mysoft/soft/Python-2.7.14/Modules/readline.o -L/usr/lib/termcap -L/home/user1/mysoft/python2.7.14/lib -L/usr/local/lib -L. -lreadline -lpython2.7 -o build/lib.linux-i686-2.7/readline.so *** WARNING: renaming "readline" since importing it failed: /usr/local/lib/libreadline.so.5: undefined symbol: BC

Python build finished, but the necessary bits to build these modules were not found: _bsddb             _sqlite3           _tkinter         bsddb185           dbm                gdbm             sunaudiodev                                            To find the necessary bits, look in setup.py in detect_modules() for the module's name. Failed to build these modules: readline 

解決 

linux系統安裝 sqlite3 sqlite-devel  readline readline-devel重新編譯安裝python,如果不安裝,出現各種問題