DEV Community

Help with Pipenv

MuziSihlongonyane on August 02, 2020

I want to start my first Django project using python in VSCode. I've gathered that I need to create a virtual environment, and I'm trying to use pipenv for this. I've installed Pipenv correctly, but when I run "pipenv shell" it gives me an error, syntax error: "invalid syntax". Why is this happening? How can I solve it?

Collapse
 
smirza profile image
Suhail

Ensure you choose the right pip environment (if you are having multiple versions of python running on your system) at the time of installing pipenv.

Run pipenv --help to see if pipenv is working otherwise.

PS: giving the entire snip of the error that you are getting from the terminal prompt would be helpful.

Collapse
 
muzisihlongonyane profile image
MuziSihlongonyane

I've recently re-installed python, and deleted the old versions I had.

When running 'pipenv --help' I get

'''

NameError Traceback (most recent call last)
in
----> 1 help(pip)

NameError: name 'pip' is not defined

'''

Collapse
 
corentinbettiol profile image
Corentin Bettiol

It's better to launch it through Python itself, aka run python3 -m pipenv install and python3 -m pipenv shell :)

Collapse
 
muzisihlongonyane profile image
MuziSihlongonyane

Fixed it. Thank you for the help👌

Collapse
 
vinmay profile image
vinmay

What fixed the issue?

Collapse
 
muzisihlongonyane profile image
MuziSihlongonyane

Beginner mistake. Installing python via Anaconda is not the same as installing python. I just installed python independently😅

Thread Thread
 
vinmay profile image
vinmay

Ah ok !

Collapse
 
vinmay profile image
vinmay

Have you created the virtual environment using something like 'python -m venv .venv' ?

Collapse
 
muzisihlongonyane profile image
MuziSihlongonyane

No I haven't. Should I?

Collapse
 
corentinbettiol profile image
Corentin Bettiol

It's using python3 venv package, which is used by pipenv :)
The command creates the virtualenv, and then you need to activate it with . .venv/bon/activate

Collapse
 
batisteo profile image
Baptiste Darthenay

You might want to use Poetry instead.

Collapse
 
muzisihlongonyane profile image
MuziSihlongonyane

Does Poetry work the same?