I'm new to python and I've been using VS code. Right now I'm working on a Thompson Sampling problem that requires numpy and matplotlib. I've imported both libraries but VS code is giving the error unable to import. I know I have to install with PIP, and I have seen other solutions about changing the Python path through the json. but I'm afraid to do that because I don't want to mess up my text editor. Can someone walk me through what I am supposed to do? I haven't seen any simple tutorials on setting up VS Code for python. I'm hoping this will help other people too! I have the extensions Python and CodeRunner installed in VS code. Thank you!
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
If you're using Python 3, the issue is most likely that when you installed numpy and matplotlib you used the
pip
command, which will only install them for Python 2. To install the libraries for Python 3 just use thepip3
command in place ofpip
.solution to this is make virtual environment for your project steps are as follows
1.go to specifid directory you want to make project.
2.open cmd or teminal an type
mkdir testProjectName
.3.type
cd testProjectName
.4.type
virtualenv venv
.5.type for windows
source venv/scripts/activate
type for linux or mac
source venv/bin/activate
6.type
pip install python
.7.type
pip install numpy
.8.type
pip install matplotlib
.9.make your project 'testProjectName' dir or copy and paste you project here.
Hope this helps.....
this happened to me when installing numpy but after i restarted VScode it fixed it's self. if that didn't work check that the package is installed with: pip list in the command prompt.