Python lxml error in Google Colab even after installing lxml with pip and pip3 - lxml

from lxml import etree command gives the below error in google colab:
ModuleNotFoundError: No module named 'lxml'
But if I try to install it with the command !pip3 install lxml or !pip install lxml it gives the below:
Requirement already satisfied: lxml in /root/.local/lib/python3.6/site-packages (4.2.5)

Mention of /root/.local/lib is strange and makes me think your VM is confused by earlier attempts. If you "reset all runtimes" to get a fresh VM does the following work for you? (it does for me)
!pip install lxml
from lxml import etree
help(etree)

Related

Can't install lxml on pip

I can't install lxml on pip or pip3
I tried run the code on python3.11
import pandas as pd
data = pd.read_html("https://zh.wikipedia.org/zh-hans/%E6%81%92%E7%94%9F%E6%8C%87%E6%95%B8")
It occurred a Import Error.
"ImportError: lxml not found, please install it"
So I tried to install the lxml. "pip install lxml"
However, it cannot be install.
** note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.**
And then, I had download the lxml-4.9.9-pp38-....whl
and entered "pip install c:/......." and it said whl is not a supported wheel on this platform.
Could someone do me a favor?

How can I fix the error "Could not find a version that satisfies the requirement torch" when trying to install PyTorch using pip?

I tried importing 'PyTorch' as 'torch' as most recent, but visual studios/cmd cannot locate nor download the package.
# Import the required modules import torch import torch.nn as nn import torch.nn.functional as F
same goes with
import tensorflow as tk
I wasn't able to download the package:
not able to find the file.
I tried both:
pip install --upgrade pip
and:
pip install torch==1.0.2
I tried all types such the basic pip install [package] to connecting the wsl.file through path
Installing older torch needs --find-index flag to pip, like torch 1.5 with cuda 10.1:
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
Reference:
https://pytorch.org/get-started/previous-versions/

Can't import pytorch_lightning on Google colab

I'm using !pip install git+https://github.com/PyTorchLightning/pytorch-lightning
but when I'm importing pytorch_lightning I get the following error:
ImportError: cannot import name '_RequirementAvailable' from 'pytorch_lightning.utilities.imports' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py)
It all worked fine a week ago...
When you install Lightning as
pip install git+https://github.com/PyTorchLightning/pytorch-lightning
you get the latest version in development. It is not an official release. I recommend installing
pip install pytorch-lightning
to get the latest stable release. I suspect this will solve your import error.

ModuleNotFoundError after installing from github

I installed the OSMNX package from GitHub with pip using
pip install git+git://github.com/gboeing/osmnx.git
and I confirmed OSMNX was installed as it showed up on pip list.
However, when trying to import osmnx I receive an error that NumPy cannot be found. I definitely have NumPy installed, and I confirmed that NumPy shows up in pip list, so I'm not sure why OSMNX can't find NumPy. Any ideas on how to make OSMNX recognize NumPy?
Here's the full error

How to install numpy on vscode on mac?

It's saying:
"ModuleNotFoundError: No module named 'numpy'"
and then when I do "pip install numpy" it says:
Requirement already satisfied: numpy in ./Library/Python/2.7/lib/python/site-packages (1.16.6)"
Probably you are using python 3.X while pip is configured for python 2.X.
Try running pip3 install numpy
Basically you are installing a package for python 2, while running the script with python 3.