Windows下配置Python(numpy,opencv)的踩雷历史

原来我还写过这个,贴一下。

C:\Windows\system32>pip list
Traceback (most recent call last):
  File "d:\python\python\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\python\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\python\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "d:\python\python\lib\site-packages\pip\_internal\cli\main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\WWW\AppData\Local\Temp\pip-build-qplium6r\opencv-python\set
up.py", line 10, in <module>
        import skbuild
    ImportError: No module named 'skbuild'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\WWW\AppD
ata\Local\Temp\pip-build-qplium6r\opencv-python
You are using pip version 7.1.2, however version 21.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

卸载重装了python,又出现了要升级的问题。

一旦升级,又出现invalid syntax问题。

卸载,忽视升级问题,重新安装。

C:\Users\WWW>pip install opencv-python
Collecting opencv-python
  Using cached https://files.pythonhosted.org/packages/bb/08/9dbc183a3ac6baa95fa
bf749ddb531bd26256edfff5b6c2195eca26258e9/opencv-python-4.5.1.48.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\WWW\AppData\Local\Temp\pip-build-kp2fw54u\opencv-python\set
up.py", line 10, in <module>
        import skbuild
    ImportError: No module named 'skbuild'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\WWW\AppData\Local\Temp\pip-build-kp2fw54u\opencv-python

按照提示安装了skbuild模块,再次尝试安装opencv

C:\Users\WWW>pip install opencv-python -i http://mirrors.aliyun.com/pypi/simple/

Collecting opencv-python
  The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host mirrors.aliyun.com'.
Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python
You are using pip version 7.1.2, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Could not find a version that satisfies the requirement opencv-python (from versions: )

No matching distribution found for opencv-python

出现上述error

‘–trusted-host mirrors.aliyun.com’

出现上述warning

修改换源地址后,重新安装opencv

Command "python setup.py egg_info" failed with error code 1 in C:\Users\WWW\AppData\Local\Temp\pip-build-z24v6xtb\numpy
You are using pip version 7.1.2, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\WWW>pip install --upgrade setuptools -i http://pypi.douban.com/simple/--trusted-host pypi.douban.com
Requirement already up-to-date: setuptools in c:\users\www\appdata\local\program
s\python\python35\lib\site-packages
You are using pip version 7.1.2, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

更新了setuptools

尝试重新安装numpy,失败,仍然错误

    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\WWW\AppData\Local\Temp\pip-build-27jupq9q\numpy\setup.py",
line 30, in <module>
        raise RuntimeError("Python version >= 3.7 required.")
    

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\WWW\AppData\Local\Temp\pip-build-27jupq9q\numpy

注意到这里有个RuntimError,要求python版本。

尝试使用conda?

[3880:3D74][2021-02-04T16:14:02]i000: Did not find D:\Python\unattend.xml
[3880:3D74][2021-02-04T16:14:02]i000: Setting string variable 'ActionLikeInstalling' to value 'Installing'
[3880:3D74][2021-02-04T16:14:02]i000: Setting string variable 'ActionLikeInstallation' to value 'Setup'
[3880:3D74][2021-02-04T16:14:02]i000: Setting version variable 'WixBundleFileVersion' to value '3.7.8150.0'
[3880:3D74][2021-02-04T16:14:02]e000: Detected Windows 7 SP1 without KB2533623
[3880:3D74][2021-02-04T16:14:02]e000: KB2533623 update is required to continue.

安装3.7以上的版本提示错误,注意到KB2533623

解决:https://blog.csdn.net/lxiaoqqin/article/details/106402866

后来用了默认安装,卸载了旧版本记得把C盘的Python文件夹全部删除。

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-build
pip install SomePackage -i https://pypi.douban.com/simple

Successfully installed numpy-1.20.0 opencv-python-4.5.1.48>

安装成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 安装 Python3 和 OpenCV 首先,需要确保在 Ubuntu 系统上安装了 Python3 和 OpenCV。可以使用以下命令来安装它们: ``` sudo apt-get update sudo apt-get install python3 python3-pip sudo apt-get install libopencv-dev python3-opencv ``` 2. 安装 Visual Studio Code 可以从 Visual Studio Code 官网下载并安装适用于 Ubuntu 系统的 Visual Studio Code。 3. 安装 Python 插件 在 Visual Studio Code 中,打开 Extensions 选项卡,搜索并安装 Python 插件。安装完成后,重新启动 Visual Studio Code。 4. 创建 Python 项目 在 Visual Studio Code 中,选择 File > New Folder 来创建一个新的文件夹。然后,选择 File > Save As,将文件夹保存为 Python 项目。 5. 配置 Python 解释器 在 Visual Studio Code 中,打开 Settings 窗口。搜索并选择 Python: Python Path 选项,并将其设置为 Python3 的路径。 6. 配置 Python 环境 在 Visual Studio Code 中,选择 Terminal > New Terminal 来打开终端。在终端中,输入以下命令来安装常用的 Python 库: ``` pip3 install numpy pip3 install matplotlib ``` 7. 编写 Python 代码 在 Visual Studio Code 中,打开新建的 Python 项目。在项目中创建一个新的 Python 文件,并编写 Python 代码来测试 OpenCV 库。 8. 运行 Python 代码 在 Visual Studio Code 中,选择 Terminal > Run Task 来运行 Python 代码。选择 Python 脚本,然后可以看到 Python 代码的输出。 通过以上步骤,就可以在 Ubuntu 系统上使用 Visual Studio Code 来开发 Python 项目,并使用 OpenCV 库来处理图像。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值