mtkennerly / poetry-dynamic-versioning

Plugin for Poetry to enable dynamic versioning based on VCS tags
MIT License
616 stars 36 forks source link

No module named 'jinja2' #13

Closed 2m closed 4 years ago

2m commented 4 years ago

I am running latest ArchLinux. Installing poetry-dynamic-versioning with pip install installs it to the ~/.local/lib/python3.8/site-packages/poetry_dynamic_versioning directory:

─╼ pip install poetry-dynamic-versioning                                                                                                                                                                                               
Defaulting to user installation because normal site-packages is not writeable
Collecting poetry-dynamic-versioning
  Using cached poetry_dynamic_versioning-0.7.0-py3-none-any.whl (9.6 kB)
Requirement already satisfied: jinja2<3.0.0,>=2.11.1 in /usr/lib/python3.8/site-packages (from poetry-dynamic-versioning) (2.11.2)
Requirement already satisfied: dunamai<2.0,>=1.1 in /home/martynas/.local/lib/python3.8/site-packages (from poetry-dynamic-versioning) (1.1.0)
Requirement already satisfied: tomlkit>=0.4 in /usr/lib/python3.8/site-packages (from poetry-dynamic-versioning) (0.6.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python3.8/site-packages (from jinja2<3.0.0,>=2.11.1->poetry-dynamic-versioning) (1.1.1)
Installing collected packages: poetry-dynamic-versioning
Successfully installed poetry-dynamic-versioning-0.7.0

However then when running poetry build in a poetry project directory I get the following error:

─╼ poetry build                                                                                                                                                                                                                        
Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.8/site.py", line 169, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in <module>
      import jinja2
  ModuleNotFoundError: No module named 'jinja2'

Remainder of file ignored

But jinja2 is available in system-wide packages: /usr/lib/python3.8/site-packages

mtkennerly commented 4 years ago

Hmm, that's peculiar. Could you show me the output of these commands?

which python

which pip
pip list

which poetry
poetry debug info
poetry run which python
poetry run which pip
poetry run pip list

Also, do these commands work?

python -c 'import jinja2'
poetry run python -c 'import jinja2'
2m commented 4 years ago

Could you show me the output of these commands?

Sure. Just note that the ModuleNotFoundError I mentioned in the original post shows up on every invocation of python, so the output is a bit noisy.

─╼ which python /usr/bin/python ─╼ which pip /usr/bin/pip ─╼ pip list Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth: Traceback (most recent call last): File "/usr/lib/python3.8/site.py", line 169, in addpackage exec(line) File "", line 1, in File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in import jinja2 ModuleNotFoundError: No module named 'jinja2' Remainder of file ignored Package Version ----------------------------- ------------------ alabaster 0.7.12 ansible 2.9.9 anytree 2.8.0 apipkg 1.5 apparmor 2.13.4 appdirs 1.4.4 arandr 0.1.10 archey4 4.7.2 asn1crypto 1.3.0 astroid 2.4.1 atomicwrites 1.4.0 attrs 19.3.0 Automat 20.2.0 awscli 1.18.67 Babel 2.8.0 bcdoc 0.16.0 bcrypt 3.1.7 Beaker 1.11.0 beautifulsoup4 4.9.1 blinker 1.4 botocore 1.16.17 breezy 3.0.2 Brlapi 0.7.0 Brotli 1.0.7 brotlipy 0.7.0 btrfsutil 1.2.0 CacheControl 0.12.6 cachetools 4.1.0 cachy 0.3.0 ceph-volume 1.0.0 cephfs 2.0.0 cephfs-shell 0.0.1 certifi 2019.11.28 cffi 1.14.0 chardet 3.0.4 cleo 0.7.6 click 7.1.2 clikit 0.4.2 colorama 0.4.3 commonmark 0.9.1 configobj 5.0.6 constantly 15.1.0 contextlib2 0.6.0.post1 cryptography 2.9.2 decorator 4.4.2 deluge 2.0.4.dev23 distlib 0.3.0 distro 1.5.0 docopt 0.6.2 docutils 0.16 dogpile.cache 0.9.1 dulwich 0.19.16 dunamai 1.1.0 entrypoints 0.3 evdev 1.3.0 fastimport 0.9.8 fdroidserver 1.1.7 fido2 0.8.1 file-magic 0.4.0 filelock 3.0.12 Flask 1.1.2 freezegun 0.3.15 future 0.18.2 GeoIP 1.3.2 google-api-core 1.16.0 google-api-python-client 1.8.3 google-auth 1.11.3 google-auth-httplib2 0.0.3 googleapis-common-protos 1.51.0 greenlet 0.4.15 h11 0.9.0 h2 3.2.0 hpack 3.0.0 html5lib 1.0.1 httpie 2.1.0 httplib2 0.17.4 hyperframe 5.2.0 hyperlink 19.0.0 idna 2.9 imagesize 1.2.0 importlib-metadata 1.6.0 incremental 17.5.0 iniconfig 1.0.0 iotop 0.6 isc 2.0 isodate 0.6.0 isort 4.3.21 itsdangerous 1.1.0 jeepney 0.4.3 Jinja2 2.11.2 jmespath 0.10.0 jsonschema 3.2.0 kaitaistruct 0.8 keyring 21.2.0 keyutils 0.6 lazy-object-proxy 1.4.3 ldap3 2.7 lensfun 0.3.95 LibAppArmor 2.13.4 libfdt 1.6.0 lit 0.10.0.dev0 lockfile 0.12.2 louis 3.13.0 lutris 0.5.6 lxml 4.5.1 Mako 1.1.2 mallard-ducktype 1.0.2 Markdown 3.1.1 MarkupSafe 1.1.1 mccabe 0.6.1 meld 3.20.2 meson 0.54.2 mitmproxy 5.1.1 mock 3.0.5 more-itertools 8.3.0 msgpack 1.0.0 namcap 3.2.10 netifaces 0.10.9 nose 1.3.7 notmuch 0.29.3 oauth2client 4.1.3 olefile 0.46 openshot-qt 2.5.1 ordered-set 3.1.1 packaging 20.4 paramiko 2.7.1 passlib 1.7.2 pastel 0.2.0 pathspec 0.8.0 patiencediff 0.1.0 pbr 5.4.5 pep517 0.8.2 pew 1.2.0 pexpect 4.8.0 Pillow 6.2.1 pip 20.0.2 pipenv 2018.11.15.dev0 pkginfo 1.5.0.1 pluggy 0.13.1 ply 3.11 poetry 1.0.5 poetry-dynamic-versioning 0.8.0 progress 1.5 protobuf 3.11.4 psutil 5.7.0 ptyprocess 0.6.0 publicsuffix2 2.20191221 py 1.8.1 pyalpm 0.9.1 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycairo 1.19.1 pycountry 19.8.18 pycparser 2.20 pycryptodome 3.9.7 pyelftools 0.26 Pygments 2.6.1 PyGObject 3.36.1 PyHamcrest 1.9.0 pylev 1.3.0 pylint 2.5.2 PyNaCl 1.3.0 pynvim 0.4.0 pyOpenSSL 19.1.0 pyparsing 2.4.7 pyPEG2 2.15.2 pyperclip 1.7.0 PyQt5 5.14.2 PyQt5-sip 12.7.2 PyQtWebEngine 5.14.0 pyrsistent 0.16.0 pyscard 1.9.9 PySocks 1.7.1 pysrt 1.1.2 pytest 5.4.2 python-dateutil 2.8.1 python-libtorrent 1.2.6 python-vagrant 0.5.15 pytoml 0.1.21 pytz 2020.1 pyusb 1.0.2 pyxdg 0.26 PyYAML 5.3.1 pyzmq 19.0.1 qutebrowser 1.11.1 rados 2.0.0 rarfile 3.1 rbd 2.0.0 rebulk 2.0.1 recommonmark 0.6.0 Reflector 2020.3.21.11.40.36 regex 2020.5.14 rencode 1.0.6 requests 2.23.0 requests-mock 1.8.0 requests-toolbelt 0.9.1 retrying 1.3.3 rgw 2.0.0 rsa 4.0 ruamel.yaml 0.16.10 ruamel.yaml.clib 0.2.0 s3cmd 2.1.0 s3transfer 0.3.3 SecretStorage 3.1.2 service-identity 18.1.0 setproctitle 1.1.10 setuptools 47.1.0 shellingham 1.3.1 six 1.15.0 snowballstemmer 2.0.0 sortedcontainers 2.1.0 soupsieve 1.9.5 speedtest-cli 2.1.2 Sphinx 3.0.4 sphinxcontrib-applehelp 1.0.2 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 1.0.3 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.4 stevedore 1.32.0 streamlink 1.3.1 team 1.0 toml 0.10.1 tomlkit 0.6.0 tornado 6.0.4 tox 3.15.1 Twisted 20.3.0 typed-ast 1.4.1 udiskie 2.2.0 uritemplate 3.0.1 urllib3 1.25.9 urwid 2.1.0 vboxapi 1.0 virtualenv 20.0.21 virtualenv-clone 0.5.4 wcwidth 0.1.9 webencodings 0.5.1 websocket-client 0.57.0 Werkzeug 1.0.1 wheel 0.34.2 wrapt 1.12.1 wsproto 0.15.0 yamllint 1.23.0 youtube-dl 2020.5.8 yubikey-manager 3.1.1 zipp 3.1.0 zope.interface 5.1.0 zstandard 0.13.0 ─╼ which poetry /usr/bin/poetry ─╼ poetry debug info Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth: Traceback (most recent call last): File "/usr/lib/python3.8/site.py", line 169, in addpackage exec(line) File "", line 1, in File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in import jinja2 ModuleNotFoundError: No module named 'jinja2' Remainder of file ignored Poetry Version: 1.0.5 Python: 3.8.3 Virtualenv Python: 3.8.3 Implementation: CPython Path: /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8 Valid: True System Platform: linux OS: posix Python: /usr ─╼ poetry run which python Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth: Traceback (most recent call last): File "/usr/lib/python3.8/site.py", line 169, in addpackage exec(line) File "", line 1, in File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in import jinja2 ModuleNotFoundError: No module named 'jinja2' Remainder of file ignored /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/bin/python ─╼ poetry run which pip Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth: Traceback (most recent call last): File "/usr/lib/python3.8/site.py", line 169, in addpackage exec(line) File "", line 1, in File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in import jinja2 ModuleNotFoundError: No module named 'jinja2' Remainder of file ignored /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/bin/pip ─╼ poetry run pip list Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth: Traceback (most recent call last): File "/usr/lib/python3.8/site.py", line 169, in addpackage exec(line) File "", line 1, in File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in import jinja2 ModuleNotFoundError: No module named 'jinja2' Remainder of file ignored Package Version Location ---------------------------- ---------- ------------------------------------------------------------------------------------------ amqp 2.5.2 appdirs 1.4.4 arrow 0.15.5 asgiref 3.2.7 attrs 19.3.0 autopep8 1.5.2 beautifulsoup4 4.9.1 billiard 3.6.3.0 black 19.10b0 cachetools 4.1.0 celery 4.4.2 celery-pool-asyncio 0.2.0 certifi 2020.4.5.1 chardet 3.0.4 click 7.1.2 Deprecated 1.2.6 entrypoints 0.3 fastdiff 0.2.0 flake8 3.8.2 flake8-bugbear 20.1.4 flake8-mypy 17.8.0 /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/src/flake8-mypy freezegun 0.3.15 google-api-core 1.17.0 google-auth 1.15.0 google-cloud-core 1.3.0 google-cloud-error-reporting 0.33.0 google-cloud-kms 1.2.1 google-cloud-logging 1.15.0 googleapis-common-protos 1.51.0 grpc-google-iam-v1 0.12.3 grpcio 1.29.0 h11 0.9.0 h2 3.2.0 hpack 3.0.0 hstspreload 2020.5.27 httpx 0.12.1 hyperframe 5.2.0 idna 2.8 jsons 1.1.2 kombu 4.6.8 mccabe 0.6.1 more-itertools 8.3.0 multidict 4.7.6 mypy 0.770 mypy-extensions 0.4.3 numpy 1.18.4 packaging 20.4 pathlib-mate 1.0.0 pathspec 0.8.0 pip 19.2.3 pluggy 0.13.1 prometheus-async 19.2.0 prometheus-client 0.7.1 protobuf 3.12.2 py 1.8.1 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycodestyle 2.6.0 pydantic 1.5 pydash 4.7.6 pyflakes 2.2.0 PyHamcrest 2.0.2 pyparsing 2.4.7 pytest 5.4.2 pytest-asyncio 0.11.0 pytest-dotenv 0.4.0 pytest-vcr 1.0.2 python-dateutil 2.8.0 python-dotenv 0.13.0 pytz 2020.1 PyYAML 5.3.1 regex 2020.5.14 requests 2.22.0 rfc3986 1.4.0 rsa 4.0 scanner-common 0.2.0 /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/src/scanner-common scanner-common-files 0.1.0 /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/src/scanner-common-files service-common 0.1.0 /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/src/service-common setuptools 41.2.0 six 1.15.0 snapshottest 0.5.1 sniffio 1.1.0 soupsieve 1.9.6 SQLAlchemy 1.3.17 taskipy 1.2.1 termcolor 1.1.0 timezonefinder 4.2.0 toml 0.10.1 typed-ast 1.4.1 typing-extensions 3.7.4.2 typish 1.6.0 urllib3 1.25.9 uszipcode 0.2.4 vcrpy 4.0.2 /home/martynas/.cache/pypoetry/virtualenvs/yyCJqX4P-py3.8/src/vcrpy vine 1.3.0 wasmer 0.4.1 wcwidth 0.1.9 wrapt 1.12.1 yarl 1.4.2 WARNING: You are using pip version 19.2.3, however version 20.1.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Also, do these commands work?

 ─╼ python -c 'import jinja2'
Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.8/site.py", line 169, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in <module>
      import jinja2
  ModuleNotFoundError: No module named 'jinja2'

Remainder of file ignored

Seems to work: the exit code is 0.

─╼ poetry run python -c 'import jinja2'
Error processing line 1 of /home/martynas/.local/lib/python3.8/site-packages/zzz_poetry_dynamic_versioning.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.8/site.py", line 169, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/home/martynas/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 7, in <module>
      import jinja2
  ModuleNotFoundError: No module named 'jinja2'

Remainder of file ignored
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'jinja2'

And this one does not.

mtkennerly commented 4 years ago

I was able to reproduce this in an Arch VM (with pip install) as well as an Ubuntu VM (with pip3 install --user). Apparently, it's specifically broken for user installs, and I didn't notice it before because my Linux test VM does non-user installs by default. For now, you should be able to avoid the issue by doing sudo pip install poetry-dynamic-versioning , but I'll try to see if there's a better solution.

2m commented 4 years ago

I see. Thanks for looking into it.

An idiomatic way to install a python package globally in Arch Linux would be to create a PKGBUILD for it ant let pacman install it. I will try to write a PKGBUILD for poetry-dynamic-versioning.

2m commented 4 years ago

I was able to create an Arch Linux package for poetry-dynamic-versioning and install it globaly by using https://github.com/anntzer/pypi2pkgbuild

pypi2pkgbuild.py poetry-dynamic-versioning

Everything works as expected now!

kaolpr commented 4 years ago

I've also come across this issue. Removing poetry installation made by get_poetry.py script and switching to pip user installation helped.