The other day, an event occurred that suddenly the python module pyquery could not be imported on VSCODE. The details of the error are as follows.
qiita.rb
Traceback (most recent call last):
File "c:\Users\name\Documents\excel_python\python_prg\today_stockinfo_toDB.py", line 1, in <module>
from pyquery import PyQuery
File "D:\Anaconda3\lib\site-packages\pyquery\__init__.py", line 7, in <module>
from .pyquery import PyQuery # NOQA
File "D:\Anaconda3\lib\site-packages\pyquery\pyquery.py", line 11, in <module>
from lxml import etree
ImportError: DLL load failed:The specified module cannot be found.
PS C:\Users\name\Documents\excel_python\python_prg> conda activate base
However, since the imporet of pyquery was created on jupyterlab without any problem, I will investigate the cause.
First, check if the module exists on vscode.
qiita.rb
$ py -m pip list
・
・
・
・
pyquery 1.4.1
was.
Next, check the path where this pyquery is stored.
qiita.rb
$ py -m pip show pyquery
・
・
・
Location: d:\anaconda3\lib\site-packages
I was able to confirm that it exists in this path.
Next, compare the path that goes around on Jupyter Lab and the path that goes around on VSCODE.
First of all, jupyterlab's
qiita.rb
import sys
sys.path
['C:\\Users\\name\\Documents\\excel_python\\python_prg',
'D:\\Anaconda3\\python37.zip',
'D:\\Anaconda3\\DLLs',
'D:\\Anaconda3\\lib',
'D:\\Anaconda3',
'',
'D:\\Anaconda3\\lib\\site-packages',
'D:\\Anaconda3\\lib\\site-packages\\win32',
'D:\\Anaconda3\\lib\\site-packages\\win32\\lib',
'D:\\Anaconda3\\lib\\site-packages\\Pythonwin',
'D:\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\name\\.ipython']
d: \ anaconda3 \ lib \ site-packages is included.
Then the one on VSCODE
qiita.rb
import sys
sys.path
'c:\\Users\\name\\Documents\\excel_python\\python_prg',
'D:\\Anaconda3\\python37.zip',
'D:\\Anaconda3\\DLLs',
'D:\\Anaconda3\\lib',
'D:\\Anaconda3',
'D:\\Anaconda3\\lib\\site-packages',
'D:\\Anaconda3\\lib\\site-packages\\win32',
'D:\\Anaconda3\\lib\\site-packages\\win32\\lib',
'D:\\Anaconda3\\lib\\site-packages\\Pythonwin']
Ah, both include d: \ anaconda3 \ lib \ site-packages. Funny, pyquery exists, both pass through the path, but on jupyterlab Can it be started and cannot be started on vscode?
I'm sorry to say that the path that VSCODE doesn't pass is'D: \ Anaconda3 \ lib \ site-packages \ IPython \ extensions','C: \ Users \ name \ .ipython' Even with vscode I tried adding it, but no improvement was seen in the symptoms. When using pyquery for a while, it seems that I will be forced to use it on jupyterlab.
Recommended Posts