简体   繁体   中英

How can I activate a virtualenv virtual environment in the anaconda prompt?

I am fairly new to using virtual environments for python projects but I have spent many hours trying to resolve this issue I've been having through various posts on this site and on others and have come up short. I have even resorted to uninstalling all python distributions and reinstalling with no luck.

I have the anaconda distribution of python installed on Windows 10. I have the problem that after I create a virtual environment, called venv, in a project folder I am unable to then activate this virtual environment using the anaconda prompt to install packages through pip. What I have done so far is as follows:

(base) C:\Users\[User]\Documents\GitHub\[project_folder]> virtualenv venv

This then successfully creates a virtual environment folder in my project folder called venv . Working in this directory I navigate to:

(base) venv> cd Scripts
(base) venv\Scripts> activate 

There are a number of activate files to choose from and neither turns the environment from base to env as expected.

The reason I am using anaconda prompt as opposed to the standard command prompt or Windows PowerShell is because when I'm using the pip install <package> anywhere but in the anaconda prompt I get an error message that reads:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

I'm not sure what this means and have tried to do some googling to solve this issue but to no avail. Note I do not have this issue when working on python projects on my MacBook and I can easily enter virtual environments and install the packages there with no issues. I'm relatively new to Windows so perhaps I'm missing something here...?

An interesting observation is that I can enter any virtual environment I've created through Windows PowerShell but I encounter the pip problem described above when trying to install packages into this environment.

I'm desperate for some help resolving this issue as it's greatly hindering the work on all my projects, and unfortunately I cannot just use my MacBook to code either.

use those command for python virtualenv

For activate 
WINDOWS: activate nameofvenv
LINUX, macOS: source activate nameofvenv

For deactivate 
WINDOWS: deactivate
macOS, LINUX: source deactivate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM