简体   繁体   中英

import error for pip install for python 3.6 packges

在此处输入图片说明

I just started playing around with python 3.6 on windows, I created a virtual enviorment for my script and in it I ran the command pip install lxml .

The package was downloaded and I can now import it in my script but when trying to import lxml.etree I get an error saying the etree is not there.

when running the following:

import lxml;
print(lxml.__file__);

The output is: my_virtual_env_path\\lib\\site-packages\\lxml\\__init__.py

this is what is printed when installing lxml with pip in my virtual env:

(env) c:\test>pip install lxml
Collecting lxml
Using cached lxml-4.2.0-cp36-cp36m-win_amd64.whl
Installing collected packages: lxml
Successfully installed lxml-4.2.0

I tried uninstalling and reinstall, doesn't solve it.

lxml is imported sucessfully, but lxml.etree is unrecognized

This is the structure of the imported lxml in my virtual enviorment:

在此处输入图片说明

What is the problem and how to solve it? Is it something that has to do with the installation?

This is a problem with your IDE. The file containing the module is present in the package -- it's <venv>\\lib\\site-packages\\lxml\\etree.cp36-win_amd64.pyd .

If you run your script directly from the virtualenv, it should work fine.

You should probably configure your IDE to use your virtualenv, not just your py3.6 installation.

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