I have an issue with virtual environment, I'm learning python so really do not know what is wrong here.
I have a folder on my desktop called 'learning' in which I am trying to make a virtual environment called venv.
When I am in VSCode I am using the terminal and write python -m venv venv which spits out the following:
PS C:\Users\XXX\Desktop\learning> virtualenv venv
created virtual environment CPython3.9.5.final.0-64 in 1553ms
creator CPython3Windows(dest=C:\Users\XXX\Desktop\learning\venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\XXX\AppData\Local\pypa\virtualenv)
added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
PS C:\Users\XXX\Desktop\learning> python -m venv venv
[{'first': 'Csr', 'last': 'vR'}, {'first': 'Jessie', 'last': 'vdd'}, {'first': 'Bill', 'last': 'Gates'}]
Traceback (most recent call last):
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 15, in <module>
import importlib.util
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\importlib\util.py", line 2, in <module>
from . import abc
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\importlib\abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\typing.py", line 22, in <module>
import collections.abc
ModuleNotFoundError: No module named 'collections.abc'; 'collections' is not a package
PS C:\Users\XXX\Desktop\learning> python -m venv try
[{'first': 'Csr', 'last': 'vR'}, {'first': 'Jessie', 'last': 'vdd'}, {'first': 'Bill', 'last': 'Gates'}]
Could not import runpy module
Traceback (most recent call last):
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 15, in <module>
import importlib.util
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\importlib\util.py", line 2, in <module>
from . import abc
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\importlib\abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\typing.py", line 22, in <module>
import collections.abc
ModuleNotFoundError: No module named 'collections.abc'; 'collections' is not a package
As you can see for some reason it is trowing back code from a file called collections.py in the folder 'learning'.. no idea why. Now when I use "virtualenv venv" it works fine, but I am trying to understand why the other command is not working.
python3 -m venv venvpython -m venv venvis supposed to create a virtual environment, but you've already created one usingvirtualenv. I suspectpython -m venvis not executing thevenvmodule in the standard library, but some other module you have locally with the same name.