20200831 更新
好久沒有編譯, 幾乎忘了命令和踩過的坑, 來看自己的筆記發現也沒有. 真是.以后還是要多筆記一下
先安裝一堆依賴
yum install gdbm-devel tk-devel xz-devel sqlite-devel readline-devel bzip2-devel ncurses-devel zlib=devel
當然gcc也是要的.
yum install gcc*
./configure --prefix=/usr/local/python3.8.5 --enable-optimizations --with-ensurepip=install
./configure prefix=/usr/local/python3.7.9 --enable-shared
#--enable-optimizations 會很慢, 如果不是生產環境, 就調過這一步吧.
#--with-ensurepip=install
#--enable-shared 這個是解決一堆編譯錯誤的
https://www.everkb.com/article/en/failed-to-build-these-modules-_ctypes-when-installing-python-3-on-centos-7
make -j 8 make altinstall
#有一步過不去, 最后 yum install zlib-devel 就好了
shell中設置代理的配置點:
export http_proxy=http://xxxx:80/ export ftp_proxy=http://xxxx:80/ export socks_proxy=socks://xxxx:80/ export https_proxy=http://xxxx:80/ export no_proxy=10.0.0.0/8,192.0.0.0/8,.xxxx,localhost,127.0.0.0/8,::1
基本上這篇文章是最全的
https://www.cnblogs.com/chuijingjing/p/10948260.html
安裝conda, 最好選擇miniconda, annaconda和系統一個annaconda居然重名,不知道系統里為什么有了一個這個東西...
安裝conda最后一步需要選擇No
You have chosen to not have conda modify your shell scripts at all. To activate conda's base environment in your current shell session: eval "$(/usr/local/miniconda/bin/conda shell.YOUR_SHELL_NAME hook)" To install conda's shell functions for easier access, first activate, then: conda init If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false: conda config --set auto_activate_base false
安裝miniconda就一句話, 下載shell, 然后執行shell,然而想看看這個shell的內容, 是不可能的, 因為文件太大了, 估計是合在一起的.
bash Miniconda3-latest-Linux-x86_64.sh
有幾個步驟, 最后一步選擇false
是交互式安裝
Miniconda3 will now be installed into this location:
/root/miniconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
后來指定一個目錄/usr/local/miniconda
這篇講得詳細
https://www.jianshu.com/p/fab0068a32b4
不過會修改.bashrc文件,加入一些東西.(干掉, 跟X系統中有個shell沖突了... centos里倒是可以)
自己在.profile中加入miniconda/bin, 就OK了.
使用pip3的包管理, 可能編程的時候可以使用,但是不能執行, 不清楚為什么, 留個疑問.
比如pip3 install jupyter之后, jupyter notebook是不能 用的,
使用conda install jupyter之后, 就可以用了.
pip3 show selenium 可以查到安裝了那些軟件
pip3包的下載目錄在安裝目錄下/usr/local/python3.7.6/lib/python3.7/site-packages
minicoda的下載目錄就在安裝目錄下, /usr/local/miniconda/pkgs
conda增加國內鏡像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
conda設置代理, 就直接編輯 ~/.condarc文件吧, 是yml格式的
proxy_servers: https: http://username:password@xxx.cn http: http://username:password@xxx.cn
官方的配置點: https://conda.io/projects/conda/en/latest/configuration.html
順便扯一下其他代理: yum的代理在/etc/yum.conf
pip代理 設置:
pip install -r requirements.txt --proxy=代理服務器IP:端口號
https://www.jianshu.com/p/eab26fdcf02e
/etc/profile 會讓所有應用都使用代理
export http_proxy=socks5://10.30.127.84:1080 export https_proxy=socks5://10.30.127.84:1080
終於踩完了一堆坑,然后使用ipython/jupyter
[root@xxx ~]# jupyter notebook [I 15:17:06.539 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret [C 15:17:07.012 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.
[root@xxx ~]# jupyter notebook --allow-root [I 15:17:32.037 NotebookApp] Serving notebooks from local directory: /root [I 15:17:32.037 NotebookApp] The Jupyter Notebook is running at: [I 15:17:32.037 NotebookApp] http://localhost:8888/?token=xxxxx [I 15:17:32.037 NotebookApp] or http://127.0.0.1:8888/?token=xxxxx [I 15:17:32.037 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 15:17:34.726 NotebookApp] To access the notebook, open this file in a browser: file:///root/.local/share/jupyter/runtime/nbserver-753-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=xxxx or http://127.0.0.1:8888/?token=xxxx
[root@xxxx xxxx]# ipython Python 3.7.4 (default, Aug 13 2019, 20:35:49) Type 'copyright', 'credits' or 'license' for more information IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help. In [1]: print("hello") hello In [2]:
ipython 使用的python是自己bin目錄下的python, 可能是安裝的時候把當時的python copy進去了.
(?, 待驗證, 因為我機器上編譯完3.7.4裝了miniconda, 后面又編譯完3.7.6, miniconda里面的python還是python3.7.4)
[xxx@xxx bin]# ll python lrwxrwxrwx 1 root root 9 1月 2 18:55 python -> python3.7 [xxx@xxx bin]# ll python3.7 -rwxrwxrwx 2 root root 12743912 8月 14 04:43 python3.7