skip to Main Content

I tried some guides that I found but nothing works. I need this virtual env for a telegram bot. I| use Visual studio code

3

Answers


  1. How to install virtualenv:
    Install pip first

    sudo apt-get install python3-pip
    

    Then install virtualenv using pip3

    sudo pip3 install virtualenv 
    

    Now create a virtual environment

    virtualenv venv 
    

    you can use any name insted of venv

    You can also use a Python interpreter of your choice

    virtualenv -p /usr/bin/python2.7 venv
    

    Active your virtual environment:

    source venv/bin/activate
    

    Using fish shell:

    source venv/bin/activate.fish
    

    To deactivate:

    deactivate
    

    Create virtualenv using Python3

    virtualenv -p python3 myenv
    

    Instead of using virtualenv you can use this command in Python3

    python3 -m venv myenv
    
    Login or Signup to reply.
    1. Install. To create a virtual environment, use the following command, where .venv is the name of the environment folder:
    python -m venv .venv
    
    1. Activate. When you create a new virtual environment, a prompt will be displayed to allow you to select it for the workspace.

    This will add the path to the Python interpreter from the new virtual environment to your workspace settings. That environment will then be used when installing packages and running code through the Python extension.

    You can switch environments at any time at the bottom left corner of VS Code window or using the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

    Login or Signup to reply.
  2. Its looks like your problem is activating the virtual environment.

    source env/bin/activate
    

    or just type activate in your terminal.

    If you are using windows try:-

    envScriptsactivate.bat
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search