Python虚拟环境安装出错:TypeError: expected str, bytes or object, not NoneType

时间:2025-02-18 09:02:03

在安装Python虚拟环境时,报了以下错误,脑子很懵。找了很多文章还是没得到解决。弄了半天,最后无奈删掉了之前创建的虚拟环境失败的那个包,最后又可以了,真的是气人


问题描述:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/", line 2632, in <module>
    main()
  File "/usr/local/lib/python3.6/dist-packages/", line 870, in main
    symlink=,
  File "/usr/local/lib/python3.6/dist-packages/", line 1156, in create_environment
    install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
  File "/home/l/.virtualenvs/py_django/lib/python3.6/", line 378, in abspath
    path = (path)
TypeError: expected str, bytes or  object, not NoneType


解决方案:

删掉之前创建失败的那个虚拟环境的包。虽然失败了,但是virtualenvs文件夹下任然保存了。删掉重新创建就可以了