5

I am new to python and I don't have much experience in constructing a good working directory. But in my past experience working with installed packages through pip, I don't have any issues.

I am trying to download, install and import spacy. According to my pip list, I see the spacy package is successfully downloaded. But when I try to create a python document on MS visual studio code, running the code import spacy in my terminal, it says

Import "spacy" could not be resolved Pylance (reportMissingImports).

When I run it on command, it says:

2021-07-10 15:41:04.164329: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-07-10 15:41:04.164530: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
INFO:tensorflow:Enabling eager execution
INFO:tensorflow:Enabling v2 tensorshape
INFO:tensorflow:Enabling resource variables
INFO:tensorflow:Enabling tensor equality
INFO:tensorflow:Enabling control flow v2

I wonder if anyone is having a clue on what is going on.

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
  • Did you notice this remark in the log: *Ignore above cudart dlerror if you do not have a GPU set up on your machine*? The message *could not be resolved* is a technical shortcoming of the linter and happens quite frequently when a library module is written in C/C++ and there is no Python implementation to check your code against. – BoarGules Jul 10 '21 at 14:57

3 Answers3

4

You can simply create a requirements.txt file where all your installs are listed. Every time you add something, update the requirements file by running pip freeze > requirements.txt and then when you activate your virtual environment, you can just run py -m pip install -r requirements.txt to fix similar issues with missing imports, etc...

Dina M.
  • 219
  • 2
  • 10
3

I managed to solved this question by setting up a virtual environment in the directory I'm working on, installing the packages I needed for the project.

0

Debug:

Terminal

  1. Create a virtual environment:
python -m venv .env
  1. Activate the virtual environment:
source .env/bin/activate  # Unix/Linux/Mac
.env\Scripts\activate.bat  # Windows
  1. or, activate conda (if not already activated):
conda create -n venv
conda activate venv
  1. Install the spacy-llm package using conda:
conda install spacy-llm
  1. Validate installation
python -m spacy validate

In VScode:

  • cmd + p

  • > Python: Select interpreter + return

  • select interpreter at workspace level: venv env python 3.11.3 virtual environment

References:

patme
  • 11
  • 2