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

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.

Related

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: How to setup virtuel enviroment?

I'm trying to set up a virtual environment for my Python + Django project, so I ran the following in my terminal:
pip3 install pipenv
Afterward while being in my folder I tried doing this
pipenv install django
but I keep getting this error, and I have no idea how to solve it. Not sure if this makes a difference but i work in VScode
zsh: command not found: pipenv
Any ideas on how to solve this problem?
With venv module
Create a virtual environment with venv
python3 -m venv .venv
Set as active environment:
source .venv/bin/activate
Install django:
pip install django
Try:
python -m pipenv install django

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

About virtualenv and version of python?

I need help in understanding with venv. I have installed venv with virtualenv venv -p python3.6.
I have activated it (venv) and install django
pip django`install django`
And so, when I work with my project should I always activate venv or not? Because I run my manage.py without venv and using python2, but I need python3.
And then I run with active venv with python3 I got mistakes like this:
ModuleNotFoundError: No module named 'forms'
I also use python3.5.2 and I created a virtual environment using the following command
python3 -m venv venv
And activated it using the following command
. venv/bin/activate
I always activate the virtual environment before running the application
You must activate the virtualenv before calling pip install ... (potentially using pip3 with Python 3.x) and also every time you need to work with the virtualenv (e.g. before calling python manage.py ...)

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

Categories

Resources