安装了npm之后(使用淘宝的镜像)http://www.jianshu.com/p/6e65d8cad6d4
安装vue 和 django ,直接运行命令行
环境:Ubuntu (阿里云)
虚拟环境: workon dv
- vue安装
cnpm install -g vue-cli
- django安装
pip install django
- mysql安装
使用mysql替换django原来的数据库sqlite3
(1) sudo apt-get install mysql-server mysql-client #全局
(2) sudo apt-get install libmysqlclient-dev #全局 ubuntu
yum install python-devel mysql-devel#全局 centos
(3) pip install MySQL-python #dv 环境
查看状态,是否安装成功。
sudo service mysql status
连接报错:
root@JoJo:~# sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
如果不执行第二条语句,ubuntu安装MySQL-python就会报以下错误:
(dv) root@JoJo:~# pip install MYSQL-python
Collecting MYSQL-python
Downloading http://mirrors.aliyun.com/pypi/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 7.1MB/s
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-zvQnlc/MYSQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zvQnlc/MYSQL-python/
如果第二条centos中,没有安装python-devel,会有如下报错: (yum install python-devel 就ok了)
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
_mysql.c:29:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/.virtualenvs/dv/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-352x1c/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-BsljrW-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.virtualenvs/dv/include/site/python2.7/MySQL-python" failed with error code 1 in /tmp/pip-build-352x1c/MySQL-python/
安装django遇到的问题:
在 pip install 的时候遇到:
Running setup.py egg_info for package django
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/root/.virtualenvs/dv/build/django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
@functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
Complete output from command python setup.py egg_info:
解决:
指定版本安装 (2017-12-11 安装)
pip install Django==1.11