Creating Virtual Environment in Windows - python

I created a virtual environment using conda create -n venv inside the project folder and activated the venv environment. However, I face the following issues:
The venv environment is getting created under C:\Users\Rajesh\anaconda3\envs folder.
When I install packages while in the venv environment, the packages not getting installed in venv folder. Please advise what is going wrong here

The default path of virtual env is located $USER/anaconda3/env, no matter where you execute the create command, the env created will be put in this path. You could change this default path by editing $HOME/.condarc:
envs_dirs:
- some path you like
pkgs_dirs:
- some path you like
Are you sure you have executed conda activate venv before installing packages?

Related

Pyenv: activate local venv

I use poetry to manage my projects dependencies and tests. I usually create a new virtual environment for each project, with a .venv directory inside of the project directory.
I would like to use pyenv virtualenv to automatically activate this projects virtualenv when inside the project directory as a local one, eg:
pyenv virtualenv local <my venv that also lives inside of this project>
Is this achievable, or do I have to create my virtualenvs inside the .pyenv directory?
When inside the project directory, any command starting poetry run will be run inside the virtual environment created by poetry.
To avoid having to use poetry run before each command, poetry shell can be used to activate the virtual environment.

Cannot activate virtual environment on virtual studio

I am using Visual Studio Code and have Anaconda downloaded so i selected it as my path interpreter.
I am able to download virtualenv using pip install virtualenv and then instantiate it using virtualenv env.
The issue occurs when I try to activate the environment using activate env or conda activate env.
Error message returned: Could not find conda environment: env. I then proceeded to look into my directory and I see that the environment is included as a folder so I'm confused on why I cannot activate it. For reference I am using Windows.
Edit: Originally the environment was not appearing in my users/.conda/environments file but using conda create --name venv I was able to create a new environment here. However, it doesn't instantiate in my current directory. Thoughts?
conda virtual environments are not interchangeable with virtualenv virtual environments. If you have created a virtual environment in your current dir. The ps command would be .\Scripts\activate

Python virtual environment not working

I have activated the python virtual environment, but anyway when I run pip install *, the dependencies are installed to my local Python path. The same happens when I run the server in my Django project: python manage.py runserver -> the system is not using the virtual environment, but the python from my PC. What is the problem? Why my activated virtual environment does not work?
I am using MacOS. Everything worked until I erased all my data and installed again Python.
Thank you!
If the packages aren't getting installed within your virtual environment, it most likely is the case that you are not using the pip within your virtual environment (or may not have pip within your virtual environment at all, in which case it is defaulting to use the pip installed in /usr/local/bin/). First, check that you have a separate version of pip in your virtual environment located in ./your_virtual_environment_name/bin/pip....If you don't, install from the PyPA download page (https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py). When you go to install a package within your virtual environment, activate the virtual environment first using source ./bin/activate inside your virtual environment, then "cd .." and you'll use the pip installed within the virtual environment by typing: ./your_virtual_environment_name/bin/pip install * ....The installation will be in ./your_virtual_environment_name/lib/python3.6/site-packages/

virtualenv activate script missing

I have installed python and virtual environment on linux, but every time I try to create a new virtual environment the bin folder is missing many files such as the activate script. I only succeed if I run the follow command:
sudo virtualenv myvenv
If I only run virtualenv myvenv the bin folder is incomplete.
I have also managed to create a virtual enviroment with python -m venv myvenv
Why is this happening I dont want to use python3, just python. Any ideas?
I had the same problem , the Scripts folder was empty.
I was trying python -m virtualenv see
and I was getting an error like :
[Errno 2] No such file or directory: 'C:\\Users\\name\\anaconda3\\Lib\\venv\\scripts\\nt\\python.exe
I changed replaced virtualenv with venv and it worked.
i.e python -m venv see

can't enable the Python virtual environment while creating an app on Mac

I am following instruction to create Mac app with Python.
I was installing Virtualenv as a part of it, as here says.
I successfully did till second step; pip install, bash_profile.
But when I try to Enable the virtual environment part, I get a. no file or directory / b&c. command not found, for each step.
By the way, this is the first time I heard .bash_profile, so the script is empty except what I did at the second step.
How can I fix the problem?
Follow simple steps
pip install virtualenv
virtualenv venv # venv is your desired name
source venv/bin/activate
I suggest you read Virtualenv User Guide.
Install virtualenv by using pip install virtualenv
virtualenv ENV to create virtual environment.
Where ENV is a directory to place the new virtual environment.
source bin/activate to activate script.
And type deactivate to undo the changes.
virtualenvwrapper
Add three lines to your shell startup file (.bashrc, .profile,
etc.) to set the location where the virtual environments should live,
the location of your development project directories, and the location
of the script installed with this package:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
Run source ~/.bashrc to reload the startup file.

Categories

Resources