Anaconda环境中无法安装PyInstaller的问题求助
问题背景
在Windows 64位系统的Anaconda myEnv环境(Python 3.10.9)中安装PyInstaller时,遇到以下问题:
- 已配置conda-forge源,但使用conda-forge提供的三种安装方式均报错
PackagesNotFoundError - 尝试
pip install pyinstaller时出现407代理认证错误 - 执行
conda update conda和从anaconda源安装(conda install -c anaconda pyinstaller)均无法解决问题
报错信息如下:
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:
- pyinstaller
pip代理错误:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/pyinstaller/
ERROR: Could not find a version that satisfies the requirement pyinstaller (from versions: none)
ERROR: No matching distribution found for pyinstaller
WARNING: There was an error checking the latest version of pip.
解决方案
1. 调整conda源优先级并清理缓存
- 清理conda本地缓存,避免旧元数据干扰:
conda clean --all - 将conda-forge源设为最高优先级,执行:
或直接编辑用户目录下的conda config --add channels conda-forge conda config --add channels defaults.condarc文件(Windows路径:C:\Users\[你的用户名]\.condarc),确保内容为:channels: - conda-forge - defaults - 重新尝试安装:
conda install pyinstaller
2. 解决pip代理认证问题
- 若必须使用pip安装,配置代理认证信息后执行:
替换括号内的内容为你的实际代理信息pip install pyinstaller --proxy http://[代理用户名]:[代理密码]@[代理地址]:[端口] - 若允许临时关闭代理,直接执行:
pip install pyinstaller
3. 指定兼容版本安装
Python 3.10.9需匹配兼容的PyInstaller版本,尝试指定版本安装:
conda install pyinstaller==5.13.0
(注:PyInstaller 5.13.0及以上版本官方支持Python 3.10)
4. 创建新环境重新安装
若以上方法均无效,创建全新环境重试:
conda create -n newPyEnv python=3.10.9 conda activate newPyEnv conda install pyinstaller
内容的提问来源于stack exchange,提问作者Diamoniner12345

