简体   繁体   中英

Error while importing requests and pyvmomi module in python

I tried to import requests in my python scripts but it shows error

>>>import requests

ImportError: No module named requests

So I tried to install it using easy_install

Path\easy_install.exe requests

in Windows, but it shows no response and when I run import again, it shows the same error.

Make sure you have requests and pyvmomi directories located under c:\\pythonXXX\\Lib\\site-packages.

In case of absence, try to install those packages via pip on windows(here you have the instructions to install pip on windows ).

Once you have done installation of pip, open the CMD prompt with administrative privilege and use the following commands to install the required python packages :

pip install requests pyvmomi

Now you could see that the packages are successfully installed.

After this, open the "System Properties" window and select "Advanced" tab and click the button "Environment variables" to set required path variables as shown below :

在此处输入图片说明

PYTHONHOME - "c:\\Python278"

PYTHONPATH - "c:\\Python278\\Lib"

Edit the system variable Path and append the following :

%PYTHONHOME%;%PYTHONPATH%;

Finally open idle or python shell and import the packages as follows :

import requests
import pyVmomi

Now you are able to import with out any problem. Whenever you import packages, also check the spelling and case sensitive of the name .

Open cmd.exe that run this command:

pip install requests

Another solution is to install Anaconda which is Python distribution that comes with great package manager from here: Anaconda

Anconda python comes with built in requests library (and many more useful libraries)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM