pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.77k stars 383 forks source link

Pycharm config doesn't work #808

Closed DanLipsitt closed 2 years ago

DanLipsitt commented 2 years ago

Marking __pypackages__/<major.minor>/lib as a sources root as described in the docs is no longer working for me. All dependencies show up as unresolved reference and are underlined with a red squiggle in the editor. I believe this started happening when I upgraded to Pycharm 2021.3. I have verified that the libraries in question are present in __pypackages__.

Python Interpreter: /opt/homebrew/opt/python@3.9/bin/python3.9 (3.9)
Project Root:       /Users/dlipsitt/src/erp-db-admin
Project Packages:   /Users/dlipsitt/src/erp-db-admin/__pypackages__/3.9
{
  "implementation_name": "cpython",
  "implementation_version": "3.9.9",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "20.3.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101",
  "python_full_version": "3.9.9",
  "platform_python_implementation": "CPython",
  "python_version": "3.9",
  "sys_platform": "darwin"
}
PyCharm 2021.3 (Professional Edition)
Build #PY-213.5744.248, built on November 29, 2021
Runtime version: 11.0.13+7-b1751.19 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 11.2.3
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Non-Bundled Plugins:
    name.kropp.intellij.makefile (213.5744.224)
    me.lensvol.blackconnect (0.4.5)
    com.jinsihou.react.snippets (1.1.0)
    org.intellij.plugins.hcl (0.7.14)
    com.faebeee.reactcomponentcreator (1.0.1)
    PlantUML integration (5.8.0)
    mobi.hsz.idea.gitignore (4.3.0)
    com.intellij.swagger (213.5744.122)
    mdx.js (1.0.213)
    com.koxudaxi.pydantic (0.3.9)
    com.intellij.bigdatatools (213.5449.109)
    ch.ristin.icontract_hypothesis_pycharm.icontract-hypothesis-pycharm (1.0.0)
    ru.adelf.idea.dotenv (2021.3.0.213)
    aws.toolkit (1.36-213)
DanLipsitt commented 2 years ago

@frostming do you use PyCharm or do we need to see if somebody else can reproduce this

frostming commented 2 years ago

Would you try this solution: https://github.com/David-OConnor/pyflow#gotchas and tell me if that works? I am not using Pycharm BTW.

DanLipsitt commented 2 years ago

Thanks @frostming. Unfortunately the intructions in the Pyflow doc do not help.

jgaines commented 2 years ago

I'm using 2021.3 Community edition at home and it's working fine for me. Two things off the top of my head:

  1. Make sure in File/Settings/Project/Project Structure, that your /Users/dlipsitt/src/erp-db-admin/__pypackages__/3.9/lib folder is actually showing up as a source folder on the right.
  2. Make sure you're using the correct major version (3.9). I ran into a little gotcha where pdm would let me pdm use and pick a 3.9 Python from the list, but because my requires-python was still set to ">=3.8.5,<3.9" in pyproject.toml, pdm silently fixed it to 3.8 version.
baggiponte commented 2 years ago

Hi! The guide in the docs works for PyCharm for me (PyCharm 2021.3.2). I am also using pyenv to manage Python versions on my machine: maybe you can try that too and see if the error still persists? Or might that be related to the fact that you're using the M1 mac? (I am still using an Intel one.)

As a side note: there is a feature request on JetBrains' YouTrack to add support for PDM, as it was done for Poetry already. If interested, please add a thumbs up to hopefully increase ints priority.

frostming commented 2 years ago

It seems to be working, i am going to close this issue.

songololo commented 2 years ago

What fixed it for me was adding __pypackages__/3.*/lib to sources (instead of __pypackages__).