conda を使用して autopy とその他のライブラリをダウンロードする

目次

I.はじめに

2. conda仮想環境の作成とライブラリのダウンロード

1.conda仮想環境を作成する

2. ソースを変更する

(1) pip変更元

(2) Conda変更元

3. ライブラリをダウンロードする

4. ダウンロードのタイムアウト処理方法 (pytorch など、ライブラリが比較的大きい場合)

5.condaでダウンロードパッケージが見つからない問題の解決方法

(1) ライブラリを検索する

(2) 対応するバージョンを確認する

 (3) ダウンロードするコマンドをコピーします。

6.requirements.txtの読み込みに失敗しました

7. autopy のダウンロードでエラーが報告されます。

3. まとめ


I.はじめに

  • 今日、ジェスチャ認識のオープンソース プロジェクトを実行しましたが、長い間ダウンロードしていませんでした。
  • それは作者がバージョン番号を明示していないからです、うおおおお!
  • このうちautopyは3.5~3.8でしか使えません!(そしてここに穴があります!)
  •  そして、私のローカル環境は3.9なので、conda仮想環境を作成する必要があります(o(╥﹏╥)o)

 

2. conda仮想環境の作成とライブラリのダウンロード

 

 ビジュアルダウンロードが苦手(放棄)


1.conda仮想環境を作成する

#------------------------------------基本操作
1.默认路径下创建新环境
conda create -n test python=3.7(name自己取名、python版本自己指定)

进阶:conda create --prefix=F:\condaenv\env_name python=3.7  #指定路径下创建环境

2.查看当前有哪些环境
conda env list

3.切换到新创建的环境
activate test  

4.退出当前环境
conda deactivate

5.删除环境
conda remove -n test --all

6、镜像源重置
conda config --remove-key channels

2. ソースを変更する

(1) pip変更元

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set install.trusted-host mirrors.aliyun.com

(2) Conda変更元

実際、この手順は必要ありません (ただし、投稿しましょう~)。後でダウンロードするには pip を使用します。

穴を踏む: 国内ミラー ステーションが conda install opencv を実行すると、現在のソース リストに opencv が見つからないというエラーが報告されます。

しかもopencvだけでなく多くのライブラリが見つからない!

# 清华源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

# 阿里源:
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/msys2
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/r
 
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/Paddle
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/auto
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/biobakery
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/bioconda
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/c4aarch64
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/caffe2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/deepmodeling
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/dglteam
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/fastai
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/fermi
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/idaholab
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/intel
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/matsci
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/menpo
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/mordred-descriptor
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/msys2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/numba
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/ohmeta
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/omnia
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/plotly
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/psi4
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch-test
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pytorch3d
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/pyviz
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/qiime2
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/rapidsai
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/rdkit
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/simpleitk
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/stackless
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/ursky
 
conda config --set show_channel_urls yes
# 镜像源重置
conda config --remove-key channels

3. ライブラリをダウンロードする


# conda下载(源列表中经常有库找不到!)请用pip
conda install --file requirements.txt

# pip下载
pip install -r requirements.txt

質問: この pip は conda にありますか?

はい、pip は通常、conda 環境で利用できるパッケージです。conda を使用して環境を作成およびアクティブ化すると、conda には環境の一部として pip が自動的に組み込まれます。

conda 環境をアクティブ化した後、コマンド ラインで pip を直接使用できます。この pip は、システム内にグローバルにインストールされている pip インスタンスから独立しており、現在アクティブな conda 環境で動作します。これにより、使用している pip が conda 環境内の他のパッケージのバージョンと互換性があることが保証されます。

したがって、conda 環境で pip を使用することは、現在アクティブ化されている conda 環境に限定されるシステム グローバル pip の使用とは異なります。

ピットを踏む: 私はかつて、この pip ダウンロードが私のグローバル pip ダウンロードを使用すると思っていましたが、その結果、私のグローバル pip ファイルにダウンロードされてしまいました。うわー!


通常であればここをインストールしたら終わりです!しかし、いいえ、以下は遭遇したピットの記録です。うわー!


4. ダウンロードのタイムアウト処理方法 (pytorch など、ライブラリが比較的大きい場合)

# conda下载设置时间(一般情况下,别用conda)
# 把连接超时的时间设置成40s,读取超时的时间修改成1000s
conda config --set remote_connect_timeout_secs 1000
conda config --set remote_read_timeout_secs 1000

# pip设置超时参数,加长时间
pip --default-timeout=1000 install name

5.condaでダウンロードパッケージが見つからない問題の解決方法

解決策: 公式 Web サイトにアクセスして、対応するバージョンのパッケージを見つけます (非推奨)

ピットを踏む: そのとき、conda によって報告されたエラーが表示され、ライブラリが見つかりませんでした。(エラーは次のように報告されます)

(test) D:\pan\桌面\GestureInteraction-main>conda install --file 111.txt
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - tf-estimator-nightly==2.8.0.dev2021122109
  - pycaw==20181226
  - pypiwin32==223
  - pyttsx3==2.90
  - mediapipe==0.8.9.1
  - autopy[version='>=4.0.0']
  - tensorflow==2.8.0
  - opt-einsum==3.3.0
  - opencv-contrib-python==4.5.5.64
  - opencv-python==4.5.5.64
  - tensorflow-io-gcs-filesystem==0.24.0

Current channels:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/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

私は愚かにもhttps://anaconda.orgに アクセスして対応するバージョンを 1 つずつ見つけて、ダウンロード コマンドを 1 つずつ実行しました。


(1) ライブラリを検索する

(2) 対応するバージョンを確認する

 

 (3) ダウンロードするコマンドをコピーします。

 まとめ:Condaのダウンロードは面倒なのでpipを使おう!


6.requirements.txtの読み込みに失敗しました

エンコードが UTF-8 ではないためです。

解決:

(方法1)自分でメモ帳を作成し、元ファイルの内容をコピーして保存!

(方法2)ソースファイルのエンコード方式を直接変更する!

(test) D:\pan\桌面\GestureInteraction-main>conda install --file requirements.txt

CondaError: Error reading file, file should be a text file containing packages
conda create --help for details

7. autopy のダウンロードでエラーが報告されます。

Building wheels for collected packages: autopy
  Building wheel for autopy (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-39
      creating build\lib.win-amd64-cpython-39\autopy
      copying autopy\__init__.py -> build\lib.win-amd64-cpython-39\autopy
      running build_ext
      running build_rust
      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for autopy
  Running setup.py clean for autopy
  error: subprocess-exited-with-error

  × python setup.py clean did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      running clean
      removing 'build\lib.win-amd64-cpython-39' (and everything under it)
      'build\bdist.win-amd64' does not exist -- can't clean it
      'build\scripts-3.9' does not exist -- can't clean it
      removing 'build'
      running clean_rust
      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed cleaning build dir for autopy
Failed to build autopy
ERROR: Could not build wheels for autopy, which is required to install pyproject.toml-based projects

解決策: [Rust コンパイラ] をダウンロードし、[コマンド プロンプト] を再起動します。

(1) Rustコンパイラをダウンロードする

  • システム パッケージ マネージャーから Rust コンパイラーをインストールし、インストール中にそれがPATHシステムの環境変数に追加されていることを確認します。(彼はそれを自動的に追加できます)
  • Rust コンパイラ ツールチェーンをダウンロードして更新するには、rustup ツールチェーン マネージャー (ダウンロード アドレス: Rustup.rs - Rust ツールチェーン インストーラー) を使用します。

 

 クリックして実行

 

 (2) コマンドプロンプトを再起動し、pip!でインストールを続けます。

3. まとめ

1. conda が仮想環境を作成したら、pip を使用してパッケージをインストールします。(condaは使用しないでください)

2. プロジェクトで環境が指定されておらず、一部のパッケージがインストールできない場合は、Pythonのバージョンの非互換性に注意してください

3. 一部のパッケージでは、追加のコンパイラをダウンロードする必要があります。パニックにならず、プロンプトに従ってダウンロードしてください。

4. ソースを変更することを忘れないでください

おすすめ

転載: blog.csdn.net/Pan_peter/article/details/131695217