I am having terrible problems with using python. I have installed Python 3.11.3. I have created a virtual environment. I activate the environment and pip install some packages. They all go off with a hitch. I create a python file within VS Code and attempt to import some installed packages. A whole raft of them do not come up in intellisense, and when I ran the code I get a "no module named:" error. This python file I am running is located in the directory for the project. I go back and look at my scripts file in the virtual environment and do a "pip list". There sit the modules I cannot use.
Are you activating the venv in VSCode?
No I activate it in cmd prompt then go back to VS Code.
(May-12-2023, 02:09 PM)jefsummers Wrote: [ -> ]Are you activating the venv in VSCode?
(May-12-2023, 01:59 PM)standenman Wrote: [ -> ]I am having terrible problems with using python. I have installed Python 3.11.3. I have created a virtual environment. I activate the environment and pip install some packages. They all go off with a hitch. I create a python file within VS Code and attempt to import some installed packages. A whole raft of them do not come up in intellisense, and when I ran the code I get a "no module named:" error. This python file I am running is located in the directory for the project. I go back and look at my scripts file in the virtual environment and do a "pip list". There sit the modules I cannot use.
I have activated the venv from a terminal in VS code. Activates properly. Again, pip list shows langchain install. Next a create a python file in VS Code, try to import "langchain" (no intellisense "langchain" offering) run it and get the "no module" error.
The basic.
# Make
G:\div_code
λ python -m venv my_env
# Cd in
G:\div_code
λ cd my_env\
# Activate
G:\div_code\my_env
λ G:\div_code\my_env\Scripts\activate.bat
# A test file
(my_env) G:\div_code\my_env
λ cat test.py
import sys
print(sys.executable)
# Start Vs Code
(my_env) G:\div_code\my_env
λ code .
So should have VS Code in Path so can use
code .
(to start VS Code from folder you are in).
Click on down in right corner over python version and it will bring up
select interpreter
as in image.
![[Image: 6KeOHi.png]](https://imagizer.imageshack.com/v2/xq70/924/6KeOHi.png)
When run
test.py
,so will now use
python.exe
in my_env folder.
Output:
g:\div_code\my_env\Scripts\python.exe