virtualenv activate script missing - python

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

Related

Why is there no existing virtual environment in setting up Django?

I successfully installed Django but when I type the command pipenv shell I get an error
/usr/bin/python3: No module named pipenv.pew
so when i also type the command pipenv --venv it says:
No virtualenv has been created for this project yet!
I'd appreciate your help, thank you!
Have you tried to setup a new virtual environment? Looks like you do not have one setup yet at all. You need to establish one first.
Try this: https://www.javatpoint.com/django-virtual-environment-setup
For VSCODE I did it like this:
# macOS/Linux
# You may need to run sudo apt-get install python3-venv first
python3 -m venv .venv
# Windows
# You can also use py -3 -m venv .venv
python -m venv .venv
> Source - https://code.visualstudio.com/docs/python/environments
Please let me know if I am off with what your asking. Just trying to help. I have python virtual environment experience but no Django.

Create fresh python venv while local have some package installed [duplicate]

I am very new at command line usage. I am using python 3.7.2, Bash and VSCode Integrated Terminal. I am trying to create a virtual environment using venv and following python documentation:
https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments
The command to use is this one:
$ python3 -m venv test-env
and I get:
bash: python3: command not found
Later I have found a similar answer in an stackoverflow post:
How to create and activate virtual environment in windows 10 using bash command
And I use the command:
py -m virtualenv test-env
and I get this:
No module named virtualenv
I am very new using the command line so i don´t really know what is going on and how to work it around.
Hi i can see that you are using two different tools to create your environment.
Those are "venv" and "virtualenv".
Venv is a library that already comes with your python installation.
Virtualenv is an external one.
I had the same problem before and the solution is very simple.
I recommend you to stick with venv because it works pretty ok and you don´t need to do extra job installing external libraries.
So for solving your problem the Bash Shell is telling you that the command Python3 has not been found.
So try instead just:
python -m venv test-env
Sometimes Python documentation is not accurate enough and I know when you start using commands, accuracy in the sintax is extremely important.
Try this steps,it'll helped you:
First, make a directory :
mkdir testing
Then, moved to this directory named testing :
cd testing
When you type following command in this directory:
python3 -m venv env (OR, python -m venv env)
You got error like :
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.8-venv
Type the following command but before that keep an eye on the version of python you installed on the machine; in my case its python3.8
sudo apt install python3.8-venv
Now, we can create a virtual environment and store its tools in the "bhandari" folder .
python3 -m venv bhandari
Note: you can named this "bhandari" folder; anyname you like( Standard practice is to name it "env" ...)
Now to activate your virtual environment, from the directory of your folder, type the following command this will activate our virtual environment in the “bhandari” folder
source bhandari/bin/activate
If you have successfully activated your virtual environment, you should see the (bhandari) word indicating that we are working in a virtual environment.
After this, we can install anything that will be isolated from the rest of the system....

Python installation directory

On command $which python3$ , the location says /opt/homebrew/bin/python3 on my Mac. Is this okay for python to be in other directory than /usr/local/ ?
Yes. It will work. I mean if you change the location of installation directory, mac os will recognize it and python3 instruction will work.
Yeah it's absolutely ok. But it's better to create a project wise virtual env so that you don't messed up installing so many third party libraries globally in your system which could break system tools and other projects.
Installing vitualenv:
python3 -m pip install --user virtualenv
Creating a virtual environment.
cd {{your project directory}}
python3 -m venv env
Activate the virtualenv:
source env/bin/activate
Now if you run which python you will see the python is from your newly created virtual env.

No activate in venv

There is no activate script in my virtual environment's bin folder.
Only files are: python, python3, python3.9.
How to fix my environment without deleting it? I'm using venv not virtualenv. I'm using Linux.
My problem is similar to this one -
There is no activate when I am trying to run my virtual env
One of answers says I should run.
python3.7 -m venv venv
But I don't understand this syntax. Should I literally write python3.9 -m venv venv into my terminal? Will it fix my enviroment?
Also I want to say that newly created environments work as expected and all the others too.
I had this problem with python 3.10, I had to install venv for my version otherwise I was missing the activate script. (I am using the deadsnake ppa on ubuntu) after this the activate script appears when creating new venv.
sudo apt-get install python3.9-venv
I documented the full python 3.10 on Ubuntu installation here
i think this is helpfull for you
but for basic use it like this:
python3.7 -m venv myenvname
source myenvname/bin/activate
and if activate isnt there try to find that in sub directories

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