简体   繁体   English

Python 使用 env 或 VS Code 解释和导入问题

[英]Python interpret and import problem with env or VS Code

I am trying to work on a university project from home.我正在尝试在家中从事大学项目。 We created a Python environment with virtualenv, all on Windows 7. I work on macOS, but when I clone the repository and launch the environment with我们使用 virtualenv 创建了一个 Python 环境,全部在 Windows 7 上。我在 macOS 上工作,但是当我克隆存储库并启动环境时

source/Users/admin/Documents/GitHub/QTLab2122/SingleIRsource/daqenv/Scripts/activate

the environment is activated.环境被激活。 But VS Code does not make me select as Python interpreter the python.exe present in Scripts and gives me error about the import of two packages: serial and niscope, despite being inside Lib.但是 VS 代码并没有让我 select 作为 Python 解释器 python.exe 出现在脚本中,并且给了我关于导入两个包的错误。 What it brings me back is它让我回来的是

"Import" serial "could not be resolved" "Import" niscope "could not be resolved" “导入”序列“无法解析”“导入”niscope“无法解析”

Is it due to the environment being created on Windows 7 and not macOS?是因为在 Windows 7 而不是 macOS 上创建的环境? Or is there something I'm missing?还是我缺少什么?

Could you find these packages in your virtual environment on your mac?你能在你的 Mac 上的虚拟环境中找到这些包吗? I think you need to reinstall these packages.我认为您需要重新安装这些软件包。

You can take pip freeze > requirements.txt to get the packages list on windows, and reinstall them on your mac through pip install -r requirements.txt .您可以通过pip freeze > requirements.txt获取 windows 上的软件包列表,然后通过pip install -r requirements.txt它们重新安装到您的 Mac 上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM