• 更换机器后的python环境中发生的这些事


    问题背景

    实验室的内网机器,系统是Ubuntu18.04,相关软件工具有Pycharm、anaconda、pip、gitlab、Firefox等。
    今天要把Ubuntu18.04上的python项目迁移到自己笔记本

    迁移目标

    源码、相关python包、开发工具

    step1-迁移源码、安装开发工具

    • 安装pycharm,导入setting.jar
    • 安装anaconda
    直至现在还有一个问题:
    当用git bash Here 打开时,会出现
    

    img

    • 拷贝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 filesanaconda3libsite-packagespip (python 3.7)
    

    但是,base中都安装不了,test2更不用说了。

    • 查资料才知道,不能直接pip install cv2,,而是intall opencv
      来来来,依旧在pycharm中install opencv:
      参考连接:install opencv-python
      img

    • 可是后来查看资料, 不能直接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
    
    • 这个时候,我想随便跑个代码给自己一点心理安慰。随便跑吧,看一眼代码片段:
      img
      这里提醒我们,写字符串路径时尽量写相对路径,不然,很容易像这样重新写

    tips:今晚就到这里,明天说

  • 相关阅读:
    双 MySQL 启动、停止脚本
    Mysql 备份与恢复
    Mysql Replication 主从同步
    SYN Flood 防范
    HTTP 1.0 & 1.1
    Memcache 内存对象缓存系统
    Redis 非关系型数据库 ( Nosql )
    Keepalived 角色选举
    Keepalived 资源监控
    keepalived
  • 原文地址:https://www.cnblogs.com/daemonFlY/p/10847265.html
Copyright © 2020-2023  润新知