简体   繁体   English

运行pipenv安装后无法使用软件包

[英]Can't use package after running pipenv install

I've just installed pipenv and then run pipenv istall pymysql which completed successfully. 我刚刚安装了pipenv,然后运行pipenv istall pymysql ,它已成功完成。 However, when trying to use pymysql with import pymysql I get an "Unable to import 'pymysql'. 但是,当尝试将pymysql与import pymysql一起使用时,出现“无法导入'pymysql'。

Here's my Pipfile: 这是我的Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
pymysql = "*"

[requires]
python_version = "3.7"

And Pipfile.lock: 和Pipfile.lock:

{
    "_meta": {
        "hash": {
            "sha256": "bcb032490d492962ce66934550b641b9c4ac4c6c46efebc19592f35358039e13"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "pymysql": {
            "hashes": [
                "sha256:3943fbbbc1e902f41daf7f9165519f140c4451c179380677e6a848587042561a",
                "sha256:d8c059dcd81dedb85a9f034d5e22dcb4442c0b201908bede99e306d65ea7c8e7"
            ],
            "index": "pypi",
            "version": "==0.9.3"
        }
    },
    "develop": {}
}

Where does pipenv even install the packages? pipenv甚至在哪里安装软件包? I can't see anything in my project folder... 我的项目文件夹中什么都看不到...

Looks like this was just a Visual Studio Code linting error. 看起来这只是一个Visual Studio Code插入错误。 When running my code it works fine. 运行我的代码时,它可以正常工作。

The fix was to hit Ctrl + Shift + P in VS Code, search for "python: select interpreter" and change the interpreter to the python.exe in the virtualenv directory. 解决方法是在VS Code中Ctrl + Shift + P ,搜索“ python:选择解释器”,然后将解释器更改为virtualenv目录中的python.exe。

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

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