Home > Enterprise >  ModuleNotFoundError: No module named 'tokenize'
ModuleNotFoundError: No module named 'tokenize'

Time:10-25

So I tried to start a Django project called 'tokenize' (using django-admin startproject tokenize) and it gave me the error -

Command Error: 'tokenize' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.

I then deleted all of my tokenize.py files from my computer and it's now giving me this error:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pip", line 5, in from pip._internal.cli.main import main File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 4, in import logging File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/logging/init.py", line 26, in import sys, os, time, io, re, traceback, warnings, weakref, collections.abc File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/traceback.py", line 5, in import linecache File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/linecache.py", line 11, in import tokenize ModuleNotFoundError: No module named 'tokenize'

I searched everywhere and can't out how to fix this issue. I know I screwed up but any assistance is appreciated.

CodePudding user response:

tokenize is a standard python library that is probably extensively used by other parts of python. You need to reinstall Python, probably after uninstalling your current installation.

It almost goes without saying, but you have to call your new project something else.

CodePudding user response:

tokenize is python standard library which you can read here :- https://docs.python.org/3/library/tokenize.html

The tokenize module provides a lexical scanner for Python source code, implemented in Python. The scanner in this module returns comments as tokens as well, making it useful for implementing “pretty-printers”, including colorizers for on-screen displays.

In order to fix your issue first of all you need to uninstall python and reinstall python on your machine. Then change your project name (tokenige) and run below command :-

django-admin startproject tokenige
  • Related