Python安装
Mac Python 2.7.16
pip安装module:
pip install flask_apscheduler --user
venv安装:
sudo pip install virtualenv
项目中生成venv文件:virtualenv venv
安装txt文件中的库:
pip install -r /workspace/server/requirements.txt
问题:
ImportError: No module named flask_apscheduler
原因还是包安装好,虽然idea提示安装成功了。之前本地装了python2.7.10和python3.7,注意安装包时看是安装在哪个python版本下。以下命令可指定安装某个python版本下:
--指定安装python版本下
sudo pip install -r requirements.txt --target=/Library/Python/2.7/site-packages
----------------------------------------------
Django安装:
pip install Django --user
查看django版本:
python -m django --version
Mac查看django安装路径:
python -c "import django; print(django.__path__)"
django安装目录:
/Users/lx/Library/Python/2.7/lib/python/site-packages/django
启动服务器:
python manage.py runserver
创建用户:
python manage.py createsuperuser
报错时执行迁移:python manage.py migrate
admin/admin123456
软连接:
sudo ln -s /Users/lx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py startproject python-web-django
-----------------------------------------------
步骤:
1、安装python
2、在idea中安装phthon插件
3、安装Virtualenv
sudo easy_install virtualenv
4、在项目中安装venv,执行以下命令:
virtualenv -p /usr/bin/python2.7 venv
5、激活相应的环境
. venv/bin/activate
6、安装flask
sudo pip3 install flask
参考:
https://blog.csdn.net/weixin_37855495/article/details/81814004
https://blog.csdn.net/baidu_36943075/article/details/90712577
安装python:
1、查看自己的python版本
python
2、查看python3的安装包
brew search python3
3、安装python3
brew install python3
参考:https://www.jianshu.com/p/95b9e1f2e5ca
--------------------------------------------------------------------------------
查看python路径:
which python3
Python idea运行参数:
runserver --port=9000
Flask-Migrate管理数据库:
python3 manage.py db init
python3 manage.py db migrate
python3 manage.py db upgrade
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
上一篇: Elasticsearch学习整理
下一篇: GitLab私服安装