美文网首页
django安装

django安装

作者: 大唐游子 | 来源:发表于2021-10-04 19:21 被阅读0次

    环境

    window10 + WLS

    django 安装

    执行安装命令:python -m pip install Django

    安装成功后出现以下警告:

      WARNING: The script sqlformat is installed in '/home/lcy/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script django-admin is installed in '/home/lcy/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    

    意思是django没有安装到PATH所在的路径中,需要将django的安装路径添加到PATH环境变量中。

    打开~/.bashrc文件,在末尾添加:

    export PATH=$PATH:/home/lcy/.local/bin
    

    mysqlclient安装

    要使数据库运行,需要安装数据库,如PostgreSQL, MariaDB, MySQL, OracleSQLite.

    还需要安装Python的数据库客户端, 如mysqlclient :

    linux下安装mysqlclient, 需要先安装一些依赖文件,再用pip安装mysqlcient即可(mysqlclient · PyPI):

    Linux

    Note that this is a basic step. I can not support complete step for build for all environment. If you can see some error, you should fix it by yourself, or ask for support in some user forum. Don't file a issue on the issue tracker.

    You may need to install the Python 3 and MySQL development headers and libraries like so:

    • $ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential # Debian / Ubuntu
    • % sudo yum install python3-devel mysql-devel # Red Hat / CentOS

    Then you can install mysqlclient via pip now:

    $ pip install mysqlclient
    

    参考

    Quick install guide | Django documentation | Django (djangoproject.com)

    How to install Django | Django documentation | Django (djangoproject.com)

    mysqlclient · PyPI

    相关文章

      网友评论

          本文标题:django安装

          本文链接:https://www.haomeiwen.com/subject/myqwnltx.html