文章目錄
服務器配置
- 使用shell命令行查看linux服務器是32位還是64位,以便下載相應的版本,返回32表示32位,返回64表示64位
getconf LONG_BIT
# 64
下載
從anaconda鏡像下載下載相對應的sh
文件。
安裝anaconda的sh文件
- 將sh文件上傳到服務器
scp /Users/jimmy/Desktop/Anaconda3-2019.07-Linux-x86_64.sh root@ip:/
- 使用shell命令行安裝anaconda
bash Anaconda3-5.3.0-Linux-x86_64.sh #第一次安裝anaconda
bash Anaconda3-5.3.0-Linux-x86_64.sh -u #已經裝過anaconda
- 一路按Enter鍵查看協議
- 輸入yes默認安裝
- 報錯
PREFIX=/root/anaconda3
Anaconda3-5.3.0-Linux-x86_64.sh: line 317: bunzip2: command not found
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
- 安裝bzip2即可解決
yum install -y bzip2
- 接下來完全默認安裝即可
啓動anaconda
- 必須重啓服務器才能登錄ipython
- 由於anaconda在linux下是安裝在一個文件夾裏/root/anaconda3 ,如果安裝過程中出錯問題,或者想更新另一個版本,刪除anaconda也很方便,執行下面命令
rm -rf ~/anaconda3
Python版本問題
卸載原始python
,linux此時自帶的python可能爲python2.7導致py3的文件報錯,可以使用如下命令移除原始python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##強制刪除已安裝程序及其關聯
whereis python |xargs rm -frv ##刪除所有殘餘文件 ##xargs,允許你對輸出執行其他某些命令
whereis python ##驗證刪除,返回無結果
程序掛起問題
- 使用如下命令可以在關閉ssh的情況下繼續運行python程序
nohup python run.py
- 並且在重新登錄服務器之後可以使用如下命令查看含有
python
字符的進程
ps aux|grep python
linux連接github
安裝git
- 在Linux上下載安裝git(以Ubuntu爲例)
sudo apt-get install git
- 報錯
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package git
- 解決辦法:
執行命令:sudo apt-get update
,在運行sudo apt-get install git
即可安裝
git --version //查看git版本
git --help //查看git幫助
連接github
- 使用如下shell命令生成公鑰,一路Enter默認安裝
ssh-keygen -t rsa -C "[email protected]"
- 此時在你運行該shell的目錄下會生成
.ssh文件夾
,將id_rsa.pub
文件的內容拷貝到github->settings->SSH and GPG keys->New SSH key 的 key
中 - 驗證是否綁定本地成功,在git-bash中驗證,輸入指令
ssh -T [email protected]
- 如果第一次執行該指令,則會提示
是否continue繼續
,如果我們輸入yes就會看到成功信息 - 設置每次commit的username和email
git config --global user.name "yourname"
git config --global user.email "youremail"
創建git本地倉庫並且初始化
mkdir /MyGit
cd /MyGit //切入工程目錄
git init //初始化
ls -a //如果有倉庫目錄下有.git表明git倉庫創建並初始化成功
關聯github上的項目庫
- 關聯遠程github項目庫
git remote add origin yourgit
yourgit
爲你要關聯的github上的項目庫的git(通過clone or download
的ssh
獲取)- 拉代碼,將github上的代碼克隆下來
git pull origin master
- 將本地的代碼同步到github上
git push -u origin master
- 強制將github覆蓋本地代碼
git fetch --all && git reset --hard origin/master && git pull