django中遇到的坑,虚拟环境下执行的命令还是在系统环境下执行了

**

问题:

**
明明已经激活了虚拟环境,但是实际执行命令时django还是用的系统环境的python路径

虚拟环境路径:
C:\Users\gg\Desktop\Dive_Into_Python\.venv

如下:

(.venv) PS C:\Users\gg\Desktop\Dive_Into_Python\django_test1> python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    main()
  File "manage.py", line 16, in main
    execute_from_command_line(sys.argv)
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    django.setup()
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\site-packages\django\apps\registry.py", line 91, in populate     
    app_config = AppConfig.create(entry)
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "E:\Program Files (x86)\python sdk 3.6.4\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'debug_toolbar'

解决方法: 删除原来的虚拟环境重新创建一个

  1. 保存原来虚拟环境下的 Lib目录
  2. 新建虚拟环境后把 Lib 目录覆盖进去
    python -m venv 虚拟环境名
  3. 重新进入虚拟环境下的Scripts目录下执行 .\Activate.ps1
  4. 检查是否成功
    pip --version
    在这里插入图片描述
    确认正在使用的虚拟环境目录下的包

其他
win10系统下查看历史剪切板上的内容 ==> win键+v 打开剪切板历史

你可能感兴趣的:(日常疑惑,python)