关于 EC2 部署 django 项目以及 pip DistributionNotFound Error。
EC2 部署 django 项目
其实不只是 django,大多数的 server 部署到 EC2 上要修改的地方其实都差不多。
三个注意点:
- 确保 EC2 的端口开了
- 修改 django project 的 settings.py,把 EC2 的 public dns 加入 ALLOWED_HOSTS
ALLOWED_HOSTS = ['ec2-52-14-223-164.us-east-2.compute.amazonaws.com']
- 开启 Server,注意监听地址
python manage.py runserver 0.0.0.0:8000
EC2 pip DistributionNotFound Error
顺便提一下 pip,好好的在安装依赖的过程中,突然出现了错误,pip 完全用不了了…
起因是某小哥突然更新了 pip… 太忧伤……小哥 Google 了若干帖子,然而事实证明,bug 这种事,有时就算试过了所有网上的解决方案也不一定能 de 出来,哪怕是卸载了重来。。
当然收获还是有的,Stack overflow 上有个解释不错
On upgrading pip on the system, as the root user, you actually overwrite your system PIP program, and are subject to severe problem when further installing Python packages for your Linux system (with yum/dnf). The correct way to work with this is to create a virtualenv as a user, and on that virtualenv you upgrade PIP. Isolated from the system Python installation. Anything remotely serious you will want to do with Python on this machine should be running at least Python 2.7 anyway - or 3.6 if it is Python 3 compatible. (Your system Python is 2.6 and you have a Python2. on /usr/local which might conflict, exactly depending on the order of PATH as you found out).
Anyway,应该是版本冲突 + 配置的问题,于是先看一下 pip 文件
|
|
要知道 pip9.0.1 其实已经有了,所以手动把所有 pip==6.1.1 改成 pip==9.0.1,然而并没有起作用。
那就直接追踪下问题出现的目录吧
|
|
然后注意了,我们确实有 pip-9.0.1,然而我们并木有 pip2.7 这个东西,有的只是 pip!所以 =>
然后,问题解决~~