skip to Main Content

I have Python3.8 built from source on my Debian 10 Xfce desktop (binaries are not available in Debian repositories). That said, whenever I can, I run my python scripts with pypy3, which I do for the sake of performance.
Now, when I run the following code with pypy3 :

#!/usr/bin/env python3.8

import requests
from bs4 import BeautifulSoup

url = input("What is the address of the  web page in question?")

response = requests.get(url)


soup = BeautifulSoup(response.text, 'html.parser')

print(soup.title.string)

I get from pypy3:

ImportError: No module named ‘requests’

The same script is run by Python3.8 without any problems

I assume that I would have to install the module in a similar way that I did it for Python, that is: sudo pip3.8 install requests.
Based on my research of a similar problem described on Stackoveflow I tried:

pypy3 -m pip3.8 install requests

and got the following from my pypy3:

Error while finding module specification for ‘pip3.8’ (ImportError: No >module named ‘pip3’)

Then I also tried to run:

pypy3 -m pip install requests

And got the following:

No module named pip

My pip3.8 works fine for Python3.8, not for my pypy3, though.

How should I look for modules in pypy3. And how should I install them?
Is the problem with installing and importing modules one of the reasons reason for the low usage of pypy3?

2

Answers


  1. Run this once to install pip itself: pypy3 -m ensurepip

    The next version of PyPy will improve the error message to describe this command explicitly when you do pypy3 -m pip and pip is not installed yet.

    Login or Signup to reply.
  2. pypy3

    Enable snaps on Debian and install pypy3

    Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single build. They update automatically and roll back gracefully.

    Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.

    Enable snapd:

        sudo apt update
        sudo apt install snapd
    

    Install pypy3:

        sudo snap install pypy3 --classic
    

    Normally, the pip and package are installed as follows

    First of all, you need to install the pip

    Install pip for Python 3

    Follow the steps below to install Pip for Python 3 on Debian:

    First, update the package list with:

       sudo apt update
    

    Next, install pip for Python 3 and all of its dependencies by typing:

       sudo apt install python3-pip
    

    Verify the installation by printing the pip version:

       pip3 --version
    

    The version number may be different, but it will look something like the one below:

       pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
    

    Pip Usage

    With pip, we can install packages from PyPI, version control, local projects, and from distribution files but in most cases, you will install packages from PyPI.

    we want to install a package named croniter, we can do that by issuing the following command:

       pip install requests
    

    To uninstall a package run:

       pip uninstall requests
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search