以下假设已激活虚拟环境

问题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

 

相关文章:

  • 2021-07-02
  • 2021-09-28
  • 2021-12-15
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-01
  • 2021-05-16
  • 2021-12-29
  • 2022-03-04
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案