django 运用pycharm的各种故障汇总(1)

一.用django入门第一个问题:pycharm的[community]社区版-免费开源与[professional]专业版注册收费两个版本:用django只能有[professional]版本便捷、专业;

解决方案的各种学习总结:

1.破解版:网上找了很多资料,基本已经没效果,不要报太大希望;

2.找中间途径然后有:Python 、Pycharm、Anaconda三者的区别与联系----

Anacoda的安装方法:

(1).安装Anacoda(建议安装Anacoda3版本)

(2).安装后电脑环境变量的设置(桌面找到这台电脑右键:点击[属性]----弹出一个窗口点击[高级系统设置]----点击[环境变量]---找到path):把安装Anaconda路径 + Anaconda3;安装Anaconda路径 + Anaconda + scrips;安装Anaconda路径 + Anaconda3 + \library\bin;(这样就把环境变量设置好了,按确定就行);

3.下载pycharm时网速太慢,又找到了下载途径:中科大镜像,清华大学开源软件镜像站,中科大镜像;

二.django运用时pycharm各自问题;

解决方案的各种学习总结:

1..pip升级:

pip install --upgrade pip

2.pip安装第三方库(模块)加载不到pycharm中:

第一步:用快捷键win+R打开运行框,输入cmd命令打开终端窗口输入:python -m site -help;查看匹配pip放置位置:




''D:\编程语言\Python\lib\site.py [--user-base] [--user-site]  

#pip安装文件放置的位置 查看lib\site.py文件

            Without arguments print some useful information
            With arguments print the value of USER_BASE and/or USER_SITE separated
            by ';'.

            Exit codes with --user-base or --user-site:
              0 - user site directory is enabled
              1 - user site directory is disabled by user
              2 - user site directory is disabled by super user
                  or for security reasons
             >2 - unknown error'''

第二步:打开文件lib\site.py查看:

USER_SITE = None

USER_BASE = None                                   

改成你要pip安装文件的位置如:

USER_SITE ='D:/编程语言/Python'                              

USER_SITE ='D:/编程语言/Python/Lib/site-packages'

就行了.

 3.python第三方库(模块)加载:
打开pycharm进入[settings]找到 [project]项 在 [project interprter] 进入 [Show All] 进入对话框 点击 [Show paths for the   selected interprter ] 把安装第三方库(模块)的文件夹添加就行;

4.升级django版本:

pip install --upgrade django==3.1.0(根据需要填写)

5.django启动pycharm出现的故障;

(1).


You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
    Run 'python manage.py migrate' to apply them.

解决方案:

python manage.py migrate

 (2).



WARNINGS:
        ?: (2_0.W001) Your URL pattern '^$' has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().

        System check identified 1 issue (0 silenced).

解决方案:

在url.py文件中:

urlpatterns = [path(r'^$', views.item),]
       改成:
urlpatterns = [path(r'item/', views.item),]

(3).



NameError: name ‘os‘ is not defined,pycharm连接Django sqlite3 

解决方案:

添加:import os

(4)




AttributeError: module 'collections' has no attribute 'Iterator'

解决方案:

建议----重新建立一个新项目,更方便!

完没,后续补充!

你可能感兴趣的:(django,pycharm,python)