Why can't I create environment with python3 on my Ubuntu?

Viewed 50
 python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

I want to create an virtual environment but received this error:

File "/usr/lib/python3.6/types.py", line 171, in <module>
    import functools as _functools
  File "/usr/lib/python3.6/functools.py", line 21, in <module>
    from collections import namedtuple
  File "/usr/lib/python3.6/collections/__init__.py", line 27, in <module>
    from keyword import iskeyword as _iskeyword
ImportError: cannot import name 'iskeyword'

Why is that?

1 Answers

I think you might have a module that share the same name keyword in your local directory. Could you try the below code

import keyword
print(dir(keyword))

And let me know what it outputs? For me it gave the following

['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'iskeyword', 'kwlist']
Related