greyli / bluelog

The 2024 version: https://github.com/greyli/greybook
MIT License
449 stars 657 forks source link

请问Python3在安装requirements.txt依赖时报错怎么办 #26

Closed Cyberbolt closed 4 years ago

Cyberbolt commented 4 years ago

下面是我的操作方法: 我通过如下方式创建虚拟环境并激活 image 然后安装 requirements.txt 时出错,如图 image image 试了很久没找到解决方法,是什么原因呢,应该怎么操作才能安装好依赖。非常感谢哦!

环境:CentOS 7,Python 3.6.8

Cyberbolt commented 4 years ago

我又在win10(Python3.8)上试了,还是相同的问题呢,请问是什么原因呢

greyli commented 4 years ago

出现这个导入报错是因为 setuptools 46.0.0 版本删掉了弃用的 Feature。解决方法有三种,你可以任选一种:

  1. 激活虚拟环境后回退到旧版本,然后重新执行安装依赖:
(venv) $ pip install setuptools==39.2.0
(venv) $ pip install -r requirements.txt
  1. 改用 venv 模块来创建虚拟环境,默认会使用旧版本的 setuptools:
    $ python3 -m venv venv
  2. 升级 MarkupSafe 到最新版本(因为你是从依赖文件安装,所以需要在 requirements.txt 里找到 MarkupSafe 这一行,然后把版本改成 1.1.1):
    MarkupSafe==1.1.1

https://discuss.helloflask.com/t/topic/458/3?u=greyli

Cyberbolt commented 4 years ago

已解决,谢谢!

pangzi499 commented 4 years ago

很抱歉我遇到类似的问题 环境:MacOS pyenv创建的pyenv-virtuals 3.6env image 问题1:当我使用 pip install -r requirements.txt image

pangzi499 commented 4 years ago

当我输入: flask forge 提示:pyenv: flask: command not found

pangzi499 commented 4 years ago

注意到: Error: pg_config executable not found.

尝试解决方法: 1.安装postgresq

brew install postgresql

2.找到相应的路径 我的路径:/usr/local/Cellar/postgresql/12.2/bin 尝试:

export PATH=/usr/local/Cellar/postgresql/12.2/bin:$PATH

3.解决问题 使用

pip install -r requirements.txt

安装成功