問題背景
實驗室的內網機器,系統是Ubuntu18.04,相關軟件工具有Pycharm、anaconda、pip、gitlab、Firefox等。
今天要把Ubuntu18.04上的python項目遷移到自己筆記本
遷移目標
源碼、相關python包、開發工具
step1-遷移源碼、安裝開發工具
- 安裝pycharm,導入setting.jar
- 安裝anaconda
直至現在還有一個問題:
當用git bash Here 打開時,會出現
- 拷貝gitlab源碼至筆記本;【未完成】打算內網穿透實驗室機器,訪問gitlab服務器
- 配置Firefox
step2-配置anaconda環境
來配置吧
-
用命令conda export > environment.yaml 導出Ubuntu中anaconda的包信息,由於Ubuntu、Windows平台的包不兼容,失敗。
-
因為我不能接觸到Ubuntu機器,且Ubuntu機器的包過多,所以直接在騰訊雲服務器上搭了FTP,將所需的anaconda包傳入FTP,然后下載至Windows。
-
anaconda包有了,但是沒有anaconda環境啊,用Pycharm生成一個吧,結果報錯CondaHTTPError問題,經過查詢,修改conda配置文件,參考連接,更改conda鏡像,選擇清華鏡像(可是清華鏡像已經停止了對anaconda的更新),先試試吧,繼續在Pycharm中生成anaconda環境,可以了。參考連接:conda的使用:
-
生成anaconda環境后,將自己之前Ubuntu中所用的包導入anaconda/env/***/conda_meta/中,看看還有什么錯誤吧。
-
pycharm提示cv2、matplotlib不存在。好吧,直接在Pycharm中install。結果報錯,提示:
Solving environment: ...working... failed
PackagesNotFoundError: The following packages are not available from current channels:
- cv2
Current channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
- 不能安裝啊,那我pip install cv2呢?結果報錯,提示:
$ pip install cv2
Collecting cv2
ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)
ERROR: No matching distribution found for cv2
注意:pip自己升級Pip
pip show pip # 查看pip版本,或者pip --version
python -m pip install --upgrade pip # upgrade pip,輸出successful
- 況且,這里的pip版本是base環境,不是我的test2環境:
pip --version
pip 19.1.1 from d:\program files\anaconda3\lib\site-packages\pip (python 3.7)
但是,base中都安裝不了,test2更不用說了。
-
查資料才知道,不能直接pip install cv2,,而是intall opencv
來來來,依舊在pycharm中install opencv:
參考連接:install opencv-python
-
可是后來查看資料, 不能直接install opencv,而是Install opencv-python
資料:/opencv-python :Installation and Usage ,
因為pycharm中的conda環境搜不到opencv-python,所以在pip中安裝,在命令行中pip install opencv-python,報錯很多。
socket.timeout: The read operation timed out。
...
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
解決辦法:
更改下載源,使用國內的:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
- 這個時候,我想隨便跑個代碼給自己一點心理安慰。隨便跑吧,看一眼代碼片段:
這里提醒我們,寫字符串路徑時盡量寫相對路徑,不然,很容易像這樣重新寫
tips:今晚就到這里,明天說