Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Setting Up a Local Python Environment Installing Python and Python Libraries Locally Using virtualenv

igsm '
igsm '
10,440 Points

Question about the location of virtualenv.

Hey! I am on Windows 7. Virtualenv gets installed in the weird location. By saying 'weird' I mean that it goes to some python folder which is in appData/Roaming ... and which is hidden. I have a main Python34 folder but installation goes to something different via appData/Roaming ... /Python/site-packages where I can see 4 files: pycache virtualenv_support virtualenv-12.0.7.dist-info virtualenv.py

Is that normal or should it be installed somewhere in different place and how can I choose location for the installation?

But I have managed to create venv in the folder Scripts which is located together with the site-packaged in the folder called Python. I do not know if that helps you to understand the situation with my folders and installations but I would like to get some explanation if everything is as it should be. Thanks

Kenneth Love

6 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

That can be normal for Windows. In Windows, Python data can be placed in the AppData folder. Additional, python packages subsequently install go in the "site-packages" directory as those packages are part of your "site" or machine configuration.

There are other Python installations for Windows that place Python at C:\PythonXY where XY is "27" or "34", etc. and site-packages at C:\PythonXY\Lib\site-packages.

If you have a Python installed in the C:\Python34 directory, it's not clear why virtualenv would install under AppData vs your 3.4 directory. It is dependent on the virtualenv installer used.

Ricky Catron
Ricky Catron
13,023 Points

I personally use an IDE to manage it or use VirtualenvWrapper. All i need to do is type "workon NameOfEnv" and it loads it. There is even a windows port here

Goodluck! --Ricky

igsm '
igsm '
10,440 Points

So, should I do anything with it? And how can i ensure that I'm working in the correct virtualenv when I use IDLE? Do we activate manually venv every time we work on a project?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Yes, you have to maually activate it every time you work on that project (and deactivate when done). If the shell / command window stays active then you don't have to restart the venv. The big advatange is you can now have have multiple venv for projects with differing needs, like conflicting package requirements.

Also checkout "virtualenvwrapper". It adds a convenience layer on top of virtualenv that keeps all your venv in a central place and allows you to give then unique names, like treehouse and coolwebsite.

Ricky Catron
Ricky Catron
13,023 Points

You could checkout PyCharm instead of IDLE, it allows you to pick a Virtualenv and use that for your project, no pesky on/off to work about, it takes a little to setup but its amazing, their is a free version and the Pro it is also free for any college students.

Goodluck! --Ricky

igsm '
igsm '
10,440 Points

How does the connection between the scripts and venv look like? How can I track which project is written in which venv? Lets assume I do not use PyCham. I activate venv via command prompt, and then I work on a script in the editor (does not matter, IDLE, canopy etc.).

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Most of the time, the virtualenv is in the same directory as the scripts you're working on, so you know they're related because they're next to each other.

Ron Chan
Ron Chan
10,987 Points

I am having exactly the same problem as Igor. After running pip install --user virtualenv, I found the files embedded deep within the hidden AppData folder without any obvious way of accessing its contents. The virtualenv.exe file is placed in separate folders from some other files installed. I have manually included the PATH in environment variables pointing to the location of the executable, but when i tried to enter a simple command (for instance virtualenv --version) I still received an error message saying 'virtualenv' is not recognized as an internal or external command. What exactly must I do get virtualenv to work?

igsm '
igsm '
10,440 Points

You can still access. AppData folder is hidden and you can show up hidden folders by Organize(in the menu of any directory, say C:/) >>> Folders and Search Options >>> then click on Views tab >>> tick 'show hidden files/folders'. Now, you are able to access AppData and further. I managed to create a new VENV being in the folder Scripts. Could be helpful to know how to get VENV installed in the main directory (not so far away), although I guess this is not an issue that prevents us from working with venv. Correct me someone if I am wrong.

Javi Venti
Javi Venti
13,030 Points

Ok, I have the same problem here. Installed virtualenv but it's in the AppData folder. Is there a command I can type to install the package in the right folder? In my case, Python is installed in C:\Python34. And once I have installed the package in the right folder, what do I type to use it correctly?

It's probably a stupid question but hey, I'm here to learn :D

Thank you, guys.

Javi Venti
Javi Venti
13,030 Points

ok, figured it out. If you get virtualenv installed in the appdata folder, just browse the folder, copy the file "virtualenv.exe" and paste it in your python folder. Then type the path that leads to that file. For instance: in my case, I pasted the file in c:\python34\lib\venv\scripts.

Therefore, I typed this in the console:

c:\python34\lib\venv\scripts\virtualenv venv

and it run!