问题描述
我是python的新手,我一直在使用VS代码.现在,我正在处理需要numpy和matplotlib的汤普森采样问题.我已经导入了两个库,但是VS代码给出了无法导入的错误.我知道我必须使用PIP进行安装,并且我已经看到了有关通过json更改Python路径的其他解决方案.但我害怕这样做,因为我不想弄乱我的文本编辑器.有人可以引导我完成我应该做的事情吗?我还没有看过任何有关为Python设置VS Code的简单教程.我希望这也会对其他人有所帮助!我在VS代码中安装了Python和CodeRunner扩展.谢谢!
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!
推荐答案
解决方案是使您的项目的虚拟环境步骤如下
1.转到要创建项目的指定目录.
2.打开cmd或teminal类型mkdir testProjectName
.
3.输入cd testProjectName
.
4.输入virtualenv venv
.
5.Windows的类型source venv/scripts/activate
用于Linux或Mac的source venv/bin/activate
类型 6.键入pip install python
.
7.输入pip install numpy
.
8.输入pip install matplotlib
.
9.将您的项目设为"testProjectName"目录,或在此处复制并粘贴您的项目.
希望这会有所帮助.....
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.....
这篇关于无法导入VS代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!