然后等待一会儿,网速很快,CPU很慢。。。。看到下图这样的就说明成功了。
这里是创建了一个python3.7的虚拟环境,虚拟环境的名字是myvenv,你也可以命名为其他的名字,出现下图所示说明创建好了
把它改成你刚刚clone下来的文件夹的目录就可以了
点击下面的链接: /var/www/username_pythonanywhere_com_wsgi.py打开文件进行修改:
先把这段代码注释掉。 然后改一下Django部分的内容: 需要改划红线的两个地方,就是将mysite改成你的项目的名字就可以了。点击保存,返回。如果你提供的虚拟环境不正确,会提示你该目录下没有虚拟环境。正确的情况如下。
需要改两个地方的地址,一个是你的站点的static地址,一个是Django自带的admin后台的static地址,如果你没有用到admin,那就不用管了。
先关掉刚才的Bash,然后点击 Start a console in this virtualenv,在虚拟环境里新建一个console。 【注意】尽量不要输入pip3 list,特别耗费CPU。尽量不要把指令输错,记得要输入pip3
pip3 install Django pip3 install Pillow pip3 install pymysql pip3 install user_agents【问题描述】django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 【参考】:Django建站过程遇到的问题 【解决】:找到Python安装路劲下的/home/username/myvenv/lib/python3.7/site-packages/django/db/backends/mysql/base.py文件 将文件中的如下代码注释
if version < (1, 3, 3): raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)重新在项目manage.py路劲下执行如下命令即可
python manage.py makemigrations python manage.py migrate【现象】:在命令行中输入py manage.py runserver后提示出如下错误
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.这是因为Django对于mysql是不兼容的,而且你应该已经下载了pymysql
【解决】:
首先确定你在__init.py__文件中有输入如下代码: import pymysql pymysql.install_as_MySQLdb() 其次找到出现问题的文件 就是错误提示中的base.py文件,然后对这个文件进行编辑。找到如下语句,然后将这个if语句注释掉就可以了。 # 之前的代码 version = Database.version_info if version < (1, 3, 13): raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) # 修改之后的代码: version = Database.version_info # if version < (1, 3, 13): # raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)【现象】:
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) django.core.exceptions.ImproperlyConfigured: The included URLconf '<module '....urls' from '...'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.这是由于你的urls.py文件中没有设置任何的路由导致的,需要在其中简单设置一个路由。
【现象】:
File "C:\Users\username\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query query = query.decode(errors='replace') AttributeError: 'str' object has no attribute 'decode'【解决】:
#原代码: query = getattr(cursor, '_executed', None) if query is not None: query = query.decode(errors='replace') return query #修改为: query = getattr(cursor, '_executed', None) if query is not None: query = query.encode(errors='replace') return query即,将decode修改为encode,此解决方法参考在Django框架中偶遇报错:AttributeError: ‘str’ object has no attribute ‘decode’解决办法_亭有枇杷树
