zoukankan      html  css  js  c++  java
  • ubuntu14.04在虚拟环境中安装flask遇到的问题

    以下假设已激活虚拟环境

    问题1:"The C extension could not be compiled, speedups are not enabled"

    原因:当使用pip安装flask时,flask package是从源码编译的,而编译时需要一些头文件(如python.h),pythonx.x-dev包含这些头文件.

    When you use pip to install numpy, the packages is compiled from source. The pythonx.x-dev packages contain the necessary header files for linking against python.

    解决:

    apt-get install python-dev    //虚拟环境中安装package不需要加sudo,否则会安装到全局环境中

    问题2:安装了flask却无法import

    原因:因为我在安装flask时加了sudo,flask安装到了全局环境,故无法导入

    问题3:安装package时遇到“Cannot fetch index base URL http://e.pypi.python.org/simple/”

    解决:加上参数"-i http://pypi.v2ex.com/simple",即换成国内镜像。

    一劳永逸的办法:~/.pip/ 下创建文件 pip.conf(如果还没有的话),并填入以下内容:

    1 [global]
    2 timeout = 6000
    3 index-url = http://pypi.v2ex.com/simple
    4 [install]
    5 use-mirrors = true
    6 mirrors = http://e.pypi.python.org

    问题3参考:http://www.cnblogs.com/Amagasaki/p/3557001.html

  • 相关阅读:
    LeetCode
    LeetCode
    Django ORM 查询
    The Usage of Pymongo
    MongoDB基操
    Django内置auth模块中login_required装饰器用于类视图的优雅方式
    Django Session配置
    Python虚拟环境
    遇见Flask-Script
    Git使用手册
  • 原文地址:https://www.cnblogs.com/bukekangli/p/4350043.html
Copyright © 2011-2022 走看看