无法在具有Python 3.4的Ubuntu 14.04上安装uWSGI(路径?) [英] Cannot install uWSGI on Ubuntu 14.04 with Python 3.4 (paths?)

查看:287
本文介绍了无法在具有Python 3.4的Ubuntu 14.04上安装uWSGI(路径?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大图是我希望具有nginx,uWGI和Python 3(virtualenv)的Ubuntu服务器启动一些项目.

The big picture is that I want Ubuntu server with nginx, uWGI, and Python 3 (virtualenv) to start some project.

我确实遵循了可以在各个地方找到的建议.尝试使用sudo pip install uwsgi安装uWSGI时,确实出现以下错误:

I did follow recommendation that can be found on various places. When trying to install uWSGI using the sudo pip install uwsgi, I do observe the following error:

plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

2012年9月,我确实发现了[J.F. Sebastian的评论] [1]关于$ sudo apt-get install python2.7-dev的必要性-这是针对python 2.7的.因此,我对Python 3.4做了类似的事情(似乎成功了).但是,我仍然观察到错误.

I did find the [J.F.Sebastian's comment][1] from September 2012 about the neccessity to $ sudo apt-get install python2.7-dev -- it was for Python 2.7. So, I did the similar for Python 3.4 (seems successfully). However, I still observer the error.

当尝试搜索Python.h时,我可以找到:

When trying to search for the Python.h, I can find:

$ locate Python.h
/usr/include/python3.4m/Python.h

要设置uWSGI,我还应该设置什么? (即使我很早就在Unix上工作,我对Ubuntu Linux还是相当陌生的.)

What else should I set to make uWSGI installed? (I am rather new to Ubuntu Linux, even though I did work with Unix far in the middle age ;)

更新:

根据下面注释中jwalker的建议,我在激活的virtualenv中执行了pip install uwsgi,并且没有sudo.但是安装程序无法在venv目录中创建子目录(如build).我尝试chmod go+w获取venv,但没有帮助.我承认我对virtualenv和pip一无所知,而且我的Unix知识还是有点生锈:

Following the jwalker's advice from the comment below, I did pip install uwsgi from within activated virtualenv and without sudo. But then the installer cannot create subdirectories (like build) in the venv directory. I tried to chmod go+w for the venv, but it did not help. I admit I know nothing about virtualenv and pip, and also my Unix knowledge is a bit rusty:

  ...
  File "/var/www/hec_project/hec_venv/lib/python3.4/site-packages/pip/req.py", line 218, in build_location
    _make_build_dir(build_dir)
  File "/var/www/hec_project/hec_venv/lib/python3.4/site-packages/pip/req.py", line 1527, in _make_build_dir
    os.makedirs(build_dir)
  File "/var/www/hec_project/hec_venv/lib/python3.4/os.py", line 237, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/var/www/hec_project/hec_venv/build'

Storing debug log for failure in /home/hecadmin/.pip/pip.log

推荐答案

安装Python 3:

Install Python 3:

sudo apt-get install python3

安装Python 3标头以从源代码构建uWSGI:

Install Python 3 headers to build uWSGI from source:

sudo apt-get install python3-dev

在当前目录的venv子目录中创建Python 3 virtualenv(如果当前目录具有特权,则在命令前添加sudo)

Create a Python 3 virtualenv in a venv subdir of current dir (prepend the command with sudo if current dir is privileged):

virtualenv -p python3 venv

激活venv作为pip的目标(.source的快捷方式):

Activate the venv to be the target for pip (. is a shortcut for source):

. venv/bin/activate

最后,安装uWSGI(如果在特权目录中,再次安装sudo):

Finally, install uWSGI (again, sudo if in a privileged dir):

pip install uwsgi

这篇关于无法在具有Python 3.4的Ubuntu 14.04上安装uWSGI(路径?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆