Search code examples
pythonpython-3.xanacondasys

Python gives error in anaconda after update


I have just tried to upgrade everything in my main environment to the latest version (using conda update --all). Everything went completely fine until I actually tried to run python. I got this error message:

Traceback (most recent call last):
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 579, in <module>
    main()
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 562, in main
    known_paths = venv(known_paths)
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 494, in venv
    addsitepackages(known_paths, [sys.prefix])
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 349, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 207, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "C:\Users\Ayush\Anaconda3\lib\site.py", line 159, in addpackage
    f = open(fullname, "r")
  File "C:\Users\Ayush\Anaconda3\lib\_bootlocale.py", line 12, in getpreferredencoding
    if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'

As you can see, it looks like a problem with sys.flags. I tried googling this, but I couldn't find anyone with the same issue. I am using python 3.6.7 (python didn't update itself). This error message also appears if I try to run python in the command prompt. Here is the output of running conda update --all. Hope you can help!

EDIT: I found an issue on this issue on github here, but this doesn't give any explanations on how to fix this.

NOTE: I have also tried to install a new version of python using the installer, but that didn't work either.


Solution

  • I somehow did it - I re-installed Python, and then I tried using the command prompt, and it worked. It turned out that if I deleted my idea folder in Pycharm, it would work with the new version!