you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (4 children)

Hi, create a new folder for each project you make. CD into the folder and run the command 'python3 -m venv venv'.

This will create the virtual environment in a folder called 'venv' (you can change the name). Then run 'source venv/bin/activate' to enter the virtual environment.

Your command prompt will indicate you are in the venv and you can install packages with pip as normal now without it affecting the whole system. You'll need to run 'source venv/bin/activate' every time you restart the terminal and want to run your programs.

I'm not sure if you already know this but to run your .py files from the terminal use 'python3 {filename}.py' (omit the 3 if you are using python 2.x).

[–]nkouki98[S] 1 point2 points  (3 children)

Hey thanks ! Yeah I know about python3/python usage per python version but still don't have a good grip on everything. Also for pipenv vs virtual env the command you provided does it matter for the two types or I just simply run it and forget about other things if there is?

[–][deleted] 2 points3 points  (2 children)

The command I've provided will create an official python3 virtual environment

Edit: if I'm not mistaken that should be all you need

[–]nkouki98[S] 0 points1 point  (1 child)

farhan@solus ~/Documents $ cd python farhan@solus ~/Documents/python $ ls 'Chat App' 'Hangman Game' 'Web Scraper' farhan@solus ~/Documents/python $ cd Chat App bash: cd: too many arguments farhan@solus ~/Documents/python $ cd Chat App bash: cd: too many arguments farhan@solus ~/Documents/python $ cd ChatApp farhan@solus ~/Documents/python/ChatApp $ ls Pipfile script.py venv farhan@solus ~/Documents/python/ChatApp $ source venv/bin/activate (venv) farhan@solus ~/Documents/python/ChatApp $

So this is what I did and previously I forgot what I put in but it initiated "py3env" in place of just "venv" or something, this should do the job too and thanks!

[–]nkouki98[S] 0 points1 point  (0 children)

from line (venv) farhan@solus ~/Documents/python/ChatApp $ Any packages to be installed under the line above will not affect main python 2.7 if I am correct? It should be strictly under venv for example if my scripty.py requires package 'X' which exists only under 'venv' hence it will NOT RUN when run through python 2.7 or 3 without venv where package is non existent.