And, if you want to use that local Python version, you can indicate that to Pipenv by executing: pipenv install --python 3.8. There you can see that after the pipenv shell command has been executed, the name of the virtual environment appeared between brackets at the beginning of the line.
So to be able to use multiple versions of Python: install Python 2. x (x is any version you need) install Python 3.
I am trying to use the requests module, here is how I installed it:
[ec2-user@ip-xxx-xx-xx-xxx newslookup]$ pipenv install requests
Creating a virtualenv for this project...
Pipfile: /var/www/html/newslookup/Pipfile
Using /usr/bin/python2 (2.7.14) to create virtualenv...
ā Creating virtual environment...Already using interpreter /usr/bin/python2
No LICENSE.txt / LICENSE found in source
New python executable in /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D/bin/python2
Also creating executable in /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D/bin/python
Installing setuptools, pip, wheel...
done.
ā Successfully created virtual environment!
Virtualenv location: /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D
Creating a Pipfile for this project...
Installing requests...
Adding requests to Pipfile's [packages]...
ā Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
ā Success!
Updated Pipfile.lock (ab273c)!
Installing dependencies from Pipfile.lock (ab273c)...
š āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 5/5 ā 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Here is what it looks like when I run my script:
[ec2-user@ip-xxx-xx-xx-xxx newslookup]$ python3 nasdaq_scrape_sec.py
Traceback (most recent call last):
File "nasdaq_scrape_sec.py", line 5, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
As you can see, the problem is that when I install it, it is using python 2 instead of python 3 (Using /usr/bin/python2 (2.7.14))
How can I tell pipenv to use Python 3 instead of Python 2?
Or is there a specific python 3 way of installing requests?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With