1

I am trying to make a virtualenv in VS code. I first installed virtualenv

PS C:\Users\to\folder> pip3 install virtualenv

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in 
Python is not available.
Requirement already satisfied: virtualenv in f:\anaconda\lib\site-packages (20.4.7)
Requirement already satisfied: distlib<1,>=0.3.1 in f:\anaconda\lib\site-packages (from virtualenv) (0.3.2)
Requirement already satisfied: six<2,>=1.9.0 in f:\anaconda\lib\site-packages (from virtualenv) (1.15.0)
Requirement already satisfied: filelock<4,>=3.0.0 in f:\anaconda\lib\site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: appdirs<2,>=1.4.3 in f:\anaconda\lib\site-packages (from virtualenv) (1.4.4)

This output is different from what i was expecting according to the guide. And then when i try to create a virtual environment, this is what i get

PS C:\Users\to\folder> virtualenv env

Traceback (most recent call last):
File "f:\anaconda\lib\runpy.py", line 194, in _run_module_as_mainreturn _run_code(code, main_globals, None,
File "f:\anaconda\lib\runpy.py", line 87, in _run_codeexec(code, run_globals)
File "F:\Anaconda\Scripts\virtualenv.exe\__main__.py", line 4, in <module>
File "f:\anaconda\lib\site-packages\virtualenv\__init__.py", line 3, in <module>from .run import cli_run, session_via_cli
File "f:\anaconda\lib\site-packages\virtualenv\run\__init__.py", line 11, in <module>from ..seed.wheels.periodic_update import manual_upgrade
File "f:\anaconda\lib\site-packages\virtualenv\seed\wheels\__init__.py", line 3, in <module>from .acquire import get_wheel, pip_wheel_env_run
File "f:\anaconda\lib\site-packages\virtualenv\seed\wheels\acquire.py", line 12, in <module>from .bundle import from_bundle
File "f:\anaconda\lib\site-packages\virtualenv\seed\wheels\bundle.py", line 4, in <module>from .periodic_update import periodic_update
File "f:\anaconda\lib\site-packages\virtualenv\seed\wheels\periodic_update.py", line 10, in <module>
import ssl
File "f:\anaconda\lib\ssl.py", line 98, in <module>
import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed while importing _ssl: The specified module could not be found.

I have not launched VS code form anaconda, yet it seems to be looking into anaconda's packages to make the virtualenv.

Sharan Kumar
  • 139
  • 1
  • 2
  • 13

1 Answers1

0

It seems like you're trying to install virtualenv within Anaconda. This should not be necessary as Anaconda is an environment manager in itself. Have a look at these answers

Regarding the error itself, I do believe it because you have not activated your Anaconda environment. Have a look at this question. My solution is normally to type code from the Anaconda prompt to launch VS Code.

filiabel
  • 395
  • 1
  • 8
  • I dont want to create a virtual environment under anaconda. I want to make it for the paritcular folder i am working in. I have tried launching code after creating a virtual environment and activating it in conda. But when i do that the console in VS code still doesnt show that it is in the virtualenv as "(env)" doesnt show up. It does on the conda cmd though. – Sharan Kumar Jul 06 '21 at 11:45
  • @SharanKumar If you do not want to use Anaconda, make sure to have a separate installation of Python at your computer and select this as your interpreter in VS Code. – filiabel Jul 06 '21 at 12:22