Ubuntu1604 Django虚拟环境搭建(python版本更改)

Ubuntu1604 Django虚拟环境搭建(python版本更改)

流程概括

  1. 安装 python3.7(自带的3.5貌似不太够用)

  2. 安装Firefox和Geckodriver(Ubuntu一般自带火狐)

  3. 安装django和selenium

  4. 安装git

具体过程

  1. 安装python3.7

原有的python环境是python2.7和python3.5,但是按照教程(《python测试驱动开发》)的要求,那还是尽量安装3.7。首先就是更改为阿里源(之前一直apt-get失败的原因就是没有改源,啊我太蠢了,我太久没有干这种事情了),教程就是这一篇吧https://blog.csdn.net/qq_39779233/article/details/106875184

  1. 安装Geckodriver

按照教程在GitHub上安装,这个很好装

  1. 安装django
pip install "django<1.12"
  1. 安装selenium
sudo -H pip install -U selenium
#教程的命令是用不了的
  1. 安装git
sudo apt-get install git
  1. 搭建虚拟环境
#在Windows中
pip install virtualenvwrapper
#在macOS/Linux中
pip install --user virtualenvwrapper
echo "source virtualenvwrapper.sh" >> ~/.bashrc
source ~/.bashrc
#创建名为"superlists"的虚拟环境,并且在里面安装python3
#在macOS/Linux中
mkvirtualenv --python=python3.7 superlists
#在Windows中
mkvirtualenv --python='py -3.7 -c "import sys; print(sys.executable)"' superlists
  1. 激活和停用虚拟环境
#激活
workon superlists
#停用
deactivate

至此,django的开发环境就搭建好了,这一路上bug不断,下面是我遇到的一些我还记得起来的或者是我解决了的bug的一些解决方案,如果遇到相同的问题可以参考(妈的什么奇奇怪怪的狗逼问题都被我给碰上了),嗯,要心平气和搞磕盐哦~

*常见问题:

  1. apt-get update 出现错误“ AppStream cache update completed, but some metadata was ignored due to errors. ”https://www.cnblogs.com/G921123/p/10502165.html

  2. ModuleNotFoundError: no module names 'gdbm' : https://blog.csdn.net/shuiyixin/article/details/89397759

  3. 升级pip3 https://blog.csdn.net/weixin_43255962/article/details/90717246

  4. ModuleNotFoundError: No module named 'pip._internal' :(方法3)

    https://blog.csdn.net/wangweiwells/article/details/88374070

  5. python 虚拟环境 No module named virtualenvwrapper virtualenvwrapper.sh:https://www.jianshu.com/p/3aaa49ec0bc0

  6. vitualenvwrapper配置报错:https://blog.csdn.net/mbl114/article/details/78089741

  7. Ubuntu下python2完全卸载:https://www.jianshu.com/p/e73b5731d334

  8. Ubuntu修改默认python版本:https://blog.csdn.net/White_Idiot/article/details/78240298

  9. virtualenvwrapper.sh报错: There was a problem running the initialization hooks.解决

  10. Ubuntu安装virtualenvwrapper:https://www.jianshu.com/p/ccf098024eee

  11. 解决pip使用异常 No module named 'pip':https://www.jianshu.com/p/8cba020b284b

  12. ctrl+alt+F1~6进入不了字符界面,黑屏的解决办法:https://www.cnblogs.com/shrimp-can/p/5134426.html

  13. ubuntu16.04的terminal打不开:https://blog.csdn.net/u010420283/article/details/89222132?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromBaidu-1.control

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容