-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pylint doesn't understand imports in "development mode" #7701
Comments
pylint generally work well with pip editable installs, there's a problem specific to your installation / environnement, that we'll have a hard time debugging without more details. |
I just reproed this is a brand new venv (see transcript below). The wheel
package for this editable install is created by setuptools.
```
$ python -m venv create /home/scott/pylint-test
$ cd pylint-test/
$ . bin/activate
(pylint-test) $ pip install pyutils
Collecting pyutils
Using cached pyutils-0.0.1b6-py3-none-any.whl (262 kB)
Collecting bitstring
Using cached bitstring-3.1.9-py3-none-any.whl (38 kB)
Collecting cloudpickle
Downloading cloudpickle-2.2.0-py3-none-any.whl (25 kB)
Collecting antlr4-python3-runtime
Downloading antlr4_python3_runtime-4.11.1-py3-none-any.whl (144 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 144.2/144.2 KB 18.6 MB/s eta
0:00:00
Collecting overrides
Downloading overrides-7.3.1-py3-none-any.whl (17 kB)
Collecting holidays
Downloading holidays-0.16-py3-none-any.whl (184 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 184.6/184.6 KB 30.5 MB/s eta
0:00:00
Collecting pytz
Downloading pytz-2022.6-py2.py3-none-any.whl (498 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 498.1/498.1 KB 36.4 MB/s eta
0:00:00
Collecting kazoo
Downloading kazoo-2.9.0-py2.py3-none-any.whl (145 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 145.6/145.6 KB 47.2 MB/s eta
0:00:00
Collecting korean-lunar-calendar
Downloading korean_lunar_calendar-0.3.1-py3-none-any.whl (9.0 kB)
Collecting python-dateutil
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting convertdate>=2.3.0
Using cached convertdate-2.4.0-py3-none-any.whl (47 kB)
Collecting hijri-converter
Using cached hijri_converter-2.2.4-py3-none-any.whl (14 kB)
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pymeeus<=1,>=0.3.13
Using cached PyMeeus-0.5.11-py3-none-any.whl
Installing collected packages: pytz, pymeeus, korean-lunar-calendar,
bitstring, antlr4-python3-runtime, six, overrides, hijri-converter,
convertdate, cloudpickle, python-dateutil, kazoo, holidays, pyutils
Successfully installed antlr4-python3-runtime-4.11.1 bitstring-3.1.9
cloudpickle-2.2.0 convertdate-2.4.0 hijri-converter-2.2.4 holidays-0.16
kazoo-2.9.0 korean-lunar-calendar-0.3.1 overrides-7.3.1 pymeeus-0.5.11
python-dateutil-2.8.2 pytz-2022.6 pyutils-0.0.1b6 six-1.16.0
WARNING: You are using pip version 22.0.4; however, version 22.3 is
available.
You should consider upgrading via the '/home/scott/pylint-test/bin/python
-m pip install --upgrade pip' command.
(pylint-test) $ pip install pylint
Collecting pylint
Using cached pylint-2.15.5-py3-none-any.whl (508 kB)
Collecting tomli>=1.1.0
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting typing-extensions>=3.10.0
Downloading typing_extensions-4.4.0-py3-none-any.whl (26 kB)
Collecting dill>=0.2
Downloading dill-0.3.6-py3-none-any.whl (110 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 110.5/110.5 KB 19.7 MB/s eta
0:00:00
Collecting mccabe<0.8,>=0.6
Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Collecting astroid<=2.14.0-dev0,>=2.12.12
Using cached astroid-2.12.12-py3-none-any.whl (264 kB)
Collecting tomlkit>=0.10.1
Downloading tomlkit-0.11.6-py3-none-any.whl (35 kB)
Collecting platformdirs>=2.2.0
Using cached platformdirs-2.5.2-py3-none-any.whl (14 kB)
Collecting isort<6,>=4.2.5
Using cached isort-5.10.1-py3-none-any.whl (103 kB)
Collecting lazy-object-proxy>=1.4.0
Downloading lazy-object-proxy-1.8.0.tar.gz (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.9/41.9 KB 15.7 MB/s eta
0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting wrapt<2,>=1.11
Using cached wrapt-1.14.1.tar.gz (50 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for wrapt, since package 'wheel' is not
installed.
Building wheels for collected packages: lazy-object-proxy
Building wheel for lazy-object-proxy (pyproject.toml) ... done
Created wheel for lazy-object-proxy:
filename=lazy_object_proxy-1.8.0-cp39-cp39-freebsd_13_1_release_p2_amd64.whl
size=24727
sha256=d42878d29fa18ffa884b4bed8a97b3cc760021bda93012049fa1de6a2c53a6be
Stored in directory:
/usr/home/scott/.cache/pip/wheels/2c/73/2b/4815ab2d0a47f1fd19a48b8d7f1eaa1010e43557dd5ac4d2cb
Successfully built lazy-object-proxy
Installing collected packages: wrapt, typing-extensions, tomlkit, tomli,
platformdirs, mccabe, lazy-object-proxy, isort, dill, astroid, pylint
Running setup.py install for wrapt ... done
Successfully installed astroid-2.12.12 dill-0.3.6 isort-5.10.1
lazy-object-proxy-1.8.0 mccabe-0.7.0 platformdirs-2.5.2 pylint-2.15.5
tomli-2.0.1 tomlkit-0.11.6 typing-extensions-4.4.0 wrapt-1.14.1
WARNING: You are using pip version 22.0.4; however, version 22.3 is
available.
You should consider upgrading via the '/home/scott/pylint-test/bin/python
-m pip install --upgrade pip' command.
(pylint-test) $ cp /home/scott/pyutils/examples/reminder/reminder.py .
(pylint-test) $ pylint reminder.py
************* Module reminder
reminder.py:129:13: W1514: Using open without explicitly specifying an
encoding (unspecified-encoding)
reminder.py:175:19: W0703: Catching too general exception Exception
(broad-except)
------------------------------------------------------------------
Your code has been rated at 9.88/10 (previous run: 8.64/10, +1.23)
(pylint-test) $ pip uninstall pyutils
Found existing installation: pyutils 0.0.1b6
Uninstalling pyutils-0.0.1b6:
Would remove:
/usr/home/scott/pylint-test/lib/python3.9/site-packages/pyutils-0.0.1b6.dist-info/*
/usr/home/scott/pylint-test/lib/python3.9/site-packages/pyutils/*
Proceed (Y/n)? y
Successfully uninstalled pyutils-0.0.1b6
(pylint-test) $ cd
(pylint-test) $ cd pyutils/
(pylint-test) $ which pip
pip is /home/scott/pylint-test/bin/pip
pip is /usr/local/bin/pip
(pylint-test) $ pip install -e .
Obtaining file:///usr/home/scott/lib/release/pyutils
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: bitstring in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (3.1.9)
Requirement already satisfied: pytz in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (2022.6)
Requirement already satisfied: antlr4-python3-runtime in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (4.11.1)
Requirement already satisfied: kazoo in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (2.9.0)
Requirement already satisfied: overrides in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (7.3.1)
Requirement already satisfied: cloudpickle in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (2.2.0)
Requirement already satisfied: holidays in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
pyutils==0.0.1b6) (0.16)
Requirement already satisfied: python-dateutil in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
holidays->pyutils==0.0.1b6) (2.8.2)
Requirement already satisfied: convertdate>=2.3.0 in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
holidays->pyutils==0.0.1b6) (2.4.0)
Requirement already satisfied: hijri-converter in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
holidays->pyutils==0.0.1b6) (2.2.4)
Requirement already satisfied: korean-lunar-calendar in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
holidays->pyutils==0.0.1b6) (0.3.1)
Requirement already satisfied: six in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
kazoo->pyutils==0.0.1b6) (1.16.0)
Requirement already satisfied: pymeeus<=1,>=0.3.13 in
/usr/home/scott/pylint-test/lib/python3.9/site-packages (from
convertdate>=2.3.0->holidays->pyutils==0.0.1b6) (0.5.11)
Building wheels for collected packages: pyutils
Building editable for pyutils (pyproject.toml) ... done
Created wheel for pyutils:
filename=pyutils-0.0.1b6-0.editable-py3-none-any.whl size=6552
sha256=69e646e282fe35f18218b4a243f72824fd18efb3e27599da4b54501eaed50b39
Stored in directory:
/tmp/pip-ephem-wheel-cache-7oypqztx/wheels/d1/b8/4e/99b126b6c6fcf38f67396da4748884306f3ca2ac09c5a42df4
Successfully built pyutils
Installing collected packages: pyutils
Successfully installed pyutils-0.0.1b6
WARNING: You are using pip version 22.0.4; however, version 22.3 is
available.
You should consider upgrading via the '/home/scott/pylint-test/bin/python
-m pip install --upgrade pip' command.
(pylint-test) $ cd ~/pylint-test/
(pylint-test) $ pylint ./reminder.py
************* Module reminder
*reminder.py:15:0: E0401: Unable to import 'pyutils'
(import-error)reminder.py:16:0: E0401: Unable to import 'pyutils.ansi'
(import-error)reminder.py:17:0: E0401: Unable to import 'pyutils.datetimes'
(import-error)reminder.py:18:0: E0401: Unable to import 'pyutils.files'
(import-error)*
reminder.py:129:13: W1514: Using open without explicitly specifying an
encoding (unspecified-encoding)
reminder.py:175:19: W0703: Catching too general exception Exception
(broad-except)
------------------------------------------------------------------
Your code has been rated at 8.64/10 (previous run: 9.88/10, -1.23)
(pylint-test) $ cd ~/pylint-test/lib/python3.9/site-packages/pyutils*
(pylint-test) $ pwd
/home/scott/pylint-test/lib/python3.9/site-packages/pyutils-0.0.1b6.dist-info
(pylint-test) $ ll
drwxr-xr-x 2 scott wheel 11 Nov 01 2022 11:06a ./
drwxr-xr-x 54 scott wheel 61 Nov 01 2022 11:06a ../
-rw-r--r-- 1 scott wheel 85 Nov 01 2022 11:06a direct_url.json
-rw-r--r-- 1 scott wheel 4 Nov 01 2022 11:06a INSTALLER
-rw-r--r-- 1 scott wheel 660 Nov 01 2022 11:06a LICENSE
-rw-r--r-- 1 scott wheel 4.2K Nov 01 2022 11:06a METADATA
-rw-r--r-- 1 scott wheel 3.8K Nov 01 2022 11:06a NOTICE
-rw-r--r-- 1 scott wheel 1016 Nov 01 2022 11:06a RECORD
-rw-r--r-- 1 scott wheel 0 Nov 01 2022 11:06a REQUESTED
-rw-r--r-- 1 scott wheel 8 Nov 01 2022 11:06a top_level.txt
-rw-r--r-- 1 scott wheel 92 Nov 01 2022 11:06a WHEEL
(pylint-test) $ more direct_url.json
{"dir_info": {"editable": true}, "url":
"file:///usr/home/scott/lib/release/pyutils"}
(pylint-test) $ more top_level.txt
pyutils
(pylint-test) $ python3
Python 3.9.15 (main, Oct 22 2022, 01:13:09)
[Clang 13.0.0 ***@***.***:llvm/llvm-project.git
llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>> import pyutils
>> import pyutils.ansi
>> dir(pyutils)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__', 'ansi',
'argparse_utils', 'config', 'function_utils', 'list_utils',
'logging_utils', 'string_utils']
>>
```
…On Tue, Nov 1, 2022 at 10:42 AM Pierre Sassoulas ***@***.***> wrote:
pylint generally work well with pip editable installs, there's a problem
specific to your installation / environnement, that we'll have a hard time
debugging without more details.
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFII6FSY4D66H52X24DWGFI67ANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Can you reproduce this outside of |
Sorry, I don't understand the request. My point is that when I install the
pyutils package from PyPi it works and when I install it from a local wheel
in edit mode it doesn't work. By "reproduce it outside of PyPi" do you
mean: do not install pyutils via PyPi and have it still break? That's the
status quo. I don't know how to not install pylint except for via PyPi but
am happy to try that if this is what you meant. I can also try this
outside of virtual environments if that is helpful.
…On Tue, Nov 1, 2022 at 12:39 PM Daniël van Noord ***@***.***> wrote:
Can you reproduce this outside of PyPy? There are many variables here
that can potentially cause this (setuptools, pip, PyPy, venv etc.) Just
trying to see what the common factor is
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFKYBFI7VTYWNSOOMJTWGFWVNANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Oh my bad, I completely misread you question and thought this was happening on I think I actually already know what this issue is, namely: This is likely a duplicate of #7306. Could you test with a lower version of |
I pinned setuptools at version 63 (was 65.1) and built a new wheel for the
local package then pip installed -e . again. pylint still doesn't find the
imports.
$ pip list | grep setuptools
setuptools 63.0.0
$ pip uninstall pyutils
..
$ python -m build
...
Successfully built pyutils-0.0.1b7.tar.gz and
pyutils-0.0.1b7-py3-none-any.whl
$ pip install -e .
...
Successfully installed pyutils-0.0.1b7
$ pylint ./reminder.py
reminder.py:15:0: E0401: Unable to import 'pyutils' (import-error)
reminder.py:16:0: E0401: Unable to import 'pyutils.ansi' (import-error)
reminder.py:17:0: E0401: Unable to import 'pyutils.datetimes' (import-error)
reminder.py:18:0: E0401: Unable to import 'pyutils.files' (import-error)
...
Should I go back to an even earlier version of setuptools?
Thx,
Scott
…On Tue, Nov 1, 2022 at 2:08 PM Daniël van Noord ***@***.***> wrote:
Oh my bad, I completely misread you question and thought this was
happening on PyPy.
I think I actually already know what this issue is, namely:
pylint-dev/astroid#1752 <pylint-dev/astroid#1752>
This is likely a duplicate of #7306
<#7306>. Could you test with a
lower version of setuptools?
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFLGV3VHHFZA7DAQSR3WGGBC7ANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hm, that's weird. Although I must say I have had many issues while working on that PR with getting stuff to reproduce. |
Feel free to close as a dupe. Is the issue understood? Under my
site-packages I get a json file that seems to act as a link to the actual
code when I install -e. Is there another methodology for these development
mode installs that works better?
…On Tue, Nov 1, 2022 at 2:21 PM Daniël van Noord ***@***.***> wrote:
Hm, that's weird. Although I must say I have had many issues while working
on that PR with getting stuff to reproduce. pip doesn't always seem to
use the setuptools installation you expect it to.
It seems likely that this is a duplicate, but I can't confirm 100%
obviously..
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFJXP3YMB6BGCQTR5G3WGGCUNANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Does that also happen with the lower version of |
Yes. I just installed setuptools==62.0 and rebuilt the wheel package for
pyutils with python -m build. Then did a pip install -e . to install it.
The state of ~/venv/lib/python3.9/site-packages/pyutils* is the same as
with higher versions of setuptools. Namely, it seems to have
a direct_url.json file in there that points at where the code lives.
Pylint doesn't work with this 62.0 based install either.
…On Tue, Nov 1, 2022 at 3:02 PM Daniël van Noord ***@***.***> wrote:
Does that also happen with the lower version of setuptools?
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFMUWMF3H45RY33WLHTWGGHODANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hm, I would need to look into that. I'm almost certain we don't support that |
I am having the same issue. Installing "setupotools<63.0.0" did not fix. However, using |
Thanks Niander. Setting that envvar before doing the pip install -e .
works for me too. Under the venv's site-packages there's an egg-link file
now instead of that directory with a JSON file.
…On Tue, Nov 8, 2022 at 4:44 PM Niander Assis ***@***.***> wrote:
I am having the same issue. Installing "setupotools<63.0.0" did not fix.
However, using SETUPTOOLS_ENABLE_FEATURES="legacy-editable" did fix my
issue
—
Reply to this email directly, view it on GitHub
<#7701 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESGFFPMN4WQXRAWYMFVZPDWHLXX5ANCNFSM6AAAAAARUI2RJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'm closing as a duplicate of #7306 |
If I install a project via pip from PyPi and it is placed under lib/site-packages in my venv, pylint can find/import it just fine:
But if I install this module from local sources in development mode then pylint can't figure out code that imports it:
I've tried various workaround involving PYTHONPATH and the system path in pylint's init-hooks and found none that really work well. Is this a known bug? Is there another recommended fix or workaround for this?
The text was updated successfully, but these errors were encountered: