I've got a poetry project. My environment is Conda 22.9.0 on a windows machine with poetry version 1.2.2:
This is my pyproject.toml file:
[tool.poetry]
name = "myproject"
version = "0.1.0"
description = ""
[tool.poetry.dependencies]
# REVIEW DEPENDENCIES
python = ">=3.7,<3.11"
numpy = "*"
tensorflow = "^2.8"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
[tool.poetry.scripts]
start = "myproject.main:start"
The myproject\main.py module contains:
import tensorflow as tf
def start():
if tf.test.is_gpu_available():
print("TensorFlow is using a GPU.")
else:
print("TensorFlow is NOT using a GPU.")
If I do poetry install, it seems to work fine:
Creating virtualenv myproject in D:\Projects\myproject\dev\myproject-series-forecast\.venv
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 41 installs, 0 updates, 0 removals
• Installing certifi (2022.12.7)
• Installing charset-normalizer (2.1.1)
• Installing idna (3.4)
• Installing pyasn1 (0.4.8)
• Installing urllib3 (1.26.13)
• Installing cachetools (5.2.0)
• Installing oauthlib (3.2.2)
• Installing rsa (4.9)
• Installing six (1.16.0)
• Installing zipp (3.11.0)
• Installing requests (2.28.1)
• Installing pyasn1-modules (0.2.8)
• Installing google-auth (2.15.0)
• Installing importlib-metadata (5.2.0)
• Installing requests-oauthlib (1.3.1)
• Installing markupsafe (2.1.1)
• Installing absl-py (1.3.0)
• Installing grpcio (1.51.1)
• Installing numpy (1.21.6)
• Installing tensorboard-data-server (0.6.1)
• Installing markdown (3.4.1)
• Installing tensorboard-plugin-wit (1.8.1)
• Installing protobuf (3.19.6)
• Installing werkzeug (2.2.2)
• Installing google-auth-oauthlib (0.4.6)
• Installing astunparse (1.6.3)
• Installing flatbuffers (22.12.6)
• Installing gast (0.4.0)
• Installing google-pasta (0.2.0)
• Installing h5py (3.7.0)
• Installing keras (2.11.0)
• Installing tensorflow-estimator (2.11.0)
• Installing packaging (22.0)
• Installing opt-einsum (3.3.0)
• Installing libclang (14.0.6)
• Installing tensorboard (2.11.0)
• Installing tensorflow-io-gcs-filesystem (0.29.0)
• Installing termcolor (2.1.1)
• Installing typing-extensions (4.4.0)
• Installing wrapt (1.14.1)
• Installing tensorflow (2.11.0)
Installing the current project: myproject (0.1.0)
But when executing poetry run start I got error in import
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Python\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "D:\Projects\myproject\dev\myproject-series-forecast\myproject\main.py", line 3, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
Related
I have a problem installing a PyQt5 python package. I am in Yocto Linux environment (Hardknott kernel 5.10.35) on the Variscite board (DART-MX8M-PLUS). This is the log when I try to install with pip:
root#imx8mp-var-dart:~# pip install pyqt5
Collecting pyqt5
Using cached PyQt5-5.15.6.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 594, in setup
self.apply_user_defaults(tool)
File "/tmp/pip-install-w8dpcxmz/pyqt5_db6cfa3b68b641d3a6209736257b28c5/project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 241, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-j1_dul47/overlay/lib/python3.9/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
root#imx8mp-var-dart:~#
Instead, this is the list of currently installed python packages:
root#imx8mp-var-dart:~# pip list
Package Version
----------------- --------------
attrs 20.3.0
btrfsutil 5.10.1
cycler 0.11.0
decorator 5.0.7
deepview-rt 2.4.25
fonttools 4.29.1
future 0.18.2
gpg 1.15.1-unknown
iniparse 0.4
kiwisolver 1.3.2
libcomps 0.1.15
matplotlib 3.5.1
mne 0.24.1
numpy 1.20.1
packaging 21.3
Pillow 8.2.0
pip 22.0.3
psutil 5.8.0
pyarmnn 24.0.0
pycairo 1.20.0
PyGObject 3.38.0
pyparsing 3.0.7
python-dateutil 2.8.2
scipy 1.8.0
setuptools 60.9.3
six 1.15.0
tflite-runtime 2.4.1
toml 0.10.2
torch 1.7.1
torchvision 0.8.2
tvm 0.7.0
typing-extensions 3.7.4.3
root#imx8mp-var-dart:~#
How can it be solved? Thanks in advance!
Do not bother installing packages natively on the board,
PyQt5 is already supported by Yocto in meta-qt5, link to recipe.
Just add meta-qt5 to your bblayers.conf and :
IMAGE_INSTALL_append = " python3-pyqt5"
I have python 3.8 & 3.9 and 3.10 and 3.11 installed, however pip install does not work for 3.10 and 3.11 and only works for the rest simply please observe:
pip3 install jedi
returns:
Requirement already satisfied: jedi in /home/user/.local/lib/python3.8/site-packages (0.17.2)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /home/user/.local/lib/python3.8/site-packages (from jedi) (0.7.1)
so does:
pip install jedi
returns
Requirement already satisfied: jedi in /home/user/.local/lib/python3.8/site-packages (0.17.2)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /home/user/.local/lib/python3.8/site-packages (from jedi) (0.7.1)
as well as :
python3.8 -m pip install jedi
results in:
Requirement already satisfied: jedi in /home/c/.local/lib/python3.8/site-packages (0.17.2)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /home/c/.local/lib/python3.8/site-packages (from jedi) (0.7.1)
However
python3.10 -m pip install jedi
results in :
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
sys.exit(_main())
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 15, in <module>
from pip._internal.index.package_finder import PackageFinder
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 21, in <module>
from pip._internal.index.collector import parse_links
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 12, in <module>
from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)
Python versions are managed by alternatives
update-alternatives --query python
which returns:
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3.8
Value: /usr/bin/python3.8
Alternative: /usr/bin/python3.8
Priority: 80
and
update-alternatives --query python3
returns:
Name: python3
Link: /usr/bin/python3
Status: auto
Best: /usr/bin/python3.8
Value: /usr/bin/python3.8
Alternative: /usr/bin/python3.10
Priority: 40
Alternative: /usr/bin/python3.8
Priority: 90
I tried re-installing practically everything including python versions and the modules to no avail.
I am not too sure what is the root of the problem or actually what is the process that leads here, it only does
It's always best to run the pip as a main module with the version of Python you want to install for.
python3.9 -m pip install ...
python3.10 -m pip install ...
python3.11 -m pip install ...
If you want to force an upgrade, use the --upgrade option.
First try to install pygames
PS > py -m pip install pygames
ERROR: Could not find a version that satisfies the requirement
pygames (from versions: none)
ERROR: No matching distribution found for pygames
There is a version conflict. I have many Python versions (2.4 - 3.11) on Windows 11.
py laucher defaults to highest Python version installed.
=> specify py launcher option -xx.yy-ZZ like:
(More info: py --help)
PS > py -3.7-32 -m pip install -U pygame
Collecting pygame
Downloading pygame-2.1.2-cp37-cp37m-win32.whl (8.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
8.1/8.1 MB 1.2 MB/s
Installing collected packages: pygame
Successfully installed pygame-2.1.2
PS > py -3.7-32
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
'>>> from pygame import *'
'>>>'
Happy end!
I'm trying to use pip-compile to build my requirements.txt file and I get the following error.
Traceback (most recent call last):
File "/Users/foobar/.pyenv/versions/3.7.0/bin/pip-compile", line 11, in <module>
sys.exit(cli())
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/piptools/scripts/compile.py", line 305, in cli
for ireq in filter(is_pinned_requirement, ireqs):
File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/piptools/utils.py", line 122, in is_pinned_requirement
if ireq.editable:
AttributeError: 'ParsedRequirement' object has no attribute 'editable'
pip==21.2.4
pip-tools==6.2.0
I tried downgrading pip and pip-tools according to the pip-tools pypi website together but I can't seem to overcome this error. If anyone has suggestions, they'd be much appreciated.
Pip List
Package Version
----------------------- -----------
aiohttp 3.7.4.post0
alembic 1.4.3
asn1crypto 1.4.0
async-timeout 3.0.1
attrs 21.2.0
certifi 2021.5.30
chardet 3.0.4
click 8.0.1
colorama 0.4.3
coverage 5.5
flake8 3.8.3
greenlet 1.1.0
idna 2.10
importlib-metadata 4.6.1
Mako 1.1.4
MarkupSafe 2.0.1
mccabe 0.6.1
more-itertools 8.8.0
multidict 5.1.0
packaging 21.0
pep517 0.11.0
pg8000 1.20.0
pip 21.0.1
pip-tools 6.1.0
pluggy 0.13.1
psycopg2 2.8.5
py 1.10.0
pycodestyle 2.6.0
pyflakes 2.2.0
PyJWT 1.7.1
pyparsing 2.4.7
pytest 5.4.3
pytest-cov 2.12.0
pytest-mock 3.1.1
python-dateutil 2.8.2
python-editor 1.0.4
requests 2.24.0
scramp 1.4.0
setuptools 39.0.1
six 1.16.0
slack-sdk 3.11.0
SQLAlchemy 1.4.20
testing.common.database 2.0.3
testing.postgresql 1.3.0
toml 0.10.2
tomli 1.2.1
typing-extensions 3.10.0.0
urllib3 1.25.11
wcwidth 0.2.5
wheel 0.37.0
yarl 1.6.3
zipp 3.5.0
The error comes from pip-tools trying to access the editable attribute on the class ParsedRequirement, whereas the correct attribute name on that class is is_editable. With previous versions of pip, the object at ireq were of type InstallRequirement, which does have the attribute editable.
Try pip==20.0.2; that seems to be the last version that returned InstallRequirement instead of ParsedRequirement from the relevant method (parse_requirements).
I'm trying to use airflow with a Vertica database as a backend for metadata.
I have configured correctly the airflow.cfg file providing the string connection with Vertica and the schema name.
This is the error I keep getting when I try to run airflow initdb
Traceback (most recent call last):
File "/srv/python/virtualenvs/airflow/bin/airflow", line 32, in <module>
args.func(args)
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/airflow/bin/ cli.py", line 1096, in initdb
db.initdb(settings.RBAC)
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/airflow/util s/db.py", line 91, in initdb
upgradedb()
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/airflow/util s/db.py", line 358, in upgradedb
command.upgrade(config, 'heads')
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/comm and.py", line 254, in upgrade
script.run_env()
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/scri pt/base.py", line 427, in run_env
util.load_python_file(self.dir, 'env.py')
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/util /pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/util /compat.py", line 83, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/airflow/migr ations/env.py", line 92, in <module>
run_migrations_online()
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/airflow/migr ations/env.py", line 82, in run_migrations_online
compare_type=COMPARE_TYPE,
File "<string>", line 8, in configure
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/runt ime/environment.py", line 812, in configure
opts=opts
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/runt ime/migration.py", line 172, in configure
return MigrationContext(dialect, connection, opts, environment_context)
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/runt ime/migration.py", line 111, in __init__
self.impl = ddl.DefaultImpl.get_by_dialect(dialect)(
File "/srv/python/virtualenvs/airflow/lib/python3.6/site-packages/alembic/ddl/ impl.py", line 65, in get_by_dialect
return _impls[dialect.name]
KeyError: 'vertica'
This is the list of package installed in a dedicated virtualenv
alembic 0.9.10
apache-airflow 1.10.3
Babel 2.6.0
certifi 2019.3.9
chardet 3.0.4
Click 7.0
colorama 0.4.1
configparser 3.5.3
croniter 0.3.29
cx-Oracle 7.1.2
defusedxml 0.5.0
dill 0.2.9
docutils 0.14
Flask 1.0.2
Flask-Admin 1.5.3
Flask-AppBuilder 1.12.3
Flask-Babel 0.12.2
Flask-Caching 1.3.3
Flask-Login 0.4.1
Flask-OpenID 1.2.5
Flask-SQLAlchemy 2.3.2
flask-swagger 0.2.13
Flask-WTF 0.14.2
funcsigs 1.0.0
future 0.16.0
gitdb2 2.0.5
GitPython 2.1.11
gunicorn 19.9.0
idna 2.8
iso8601 0.1.12
itsdangerous 1.1.0
Jinja2 2.10
json-merge-patch 0.2
lockfile 0.12.2
lxml 4.3.3
Mako 1.0.8
Markdown 2.6.11
MarkupSafe 1.1.1
numpy 1.16.2
ordereddict 1.1
pandas 0.24.2
pendulum 1.4.4
pip 19.0.3
psutil 5.6.1
psycopg2 2.8.2
psycopg2-binary 2.8.2
Pygments 2.3.1
python-daemon 2.1.2
python-dateutil 2.8.0
python-editor 1.0.4
python3-openid 3.1.0
pytz 2019.1
pytzdata 2019.1
PyYAML 5.1
requests 2.21.0
setproctitle 1.1.10
setuptools 41.0.0
six 1.12.0
smmap2 2.0.5
SQLAlchemy 1.2.18
sqlalchemy-vertica-python 0.4.4
tabulate 0.8.3
tenacity 4.12.0
text-unidecode 1.2
thrift 0.11.0
tzlocal 1.5.1
unicodecsv 0.14.1
urllib3 1.24.1
vertica-python 0.9.1
Werkzeug 0.14.1
wheel 0.33.1
WTForms 2.2.1
zope.deprecation 4.4.0
Thanks
I have visual studio installed and for example I can install lxml but it does not work for PyCrypto and MySQL-python.
I am getting following error:
File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsal
l
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
My list of installed packages:
D:\>pip list
ipython (2.1.0)
lxml (3.3.5)
mysql-python (1.2.4
pip (1.5.6)
pyasn1 (0.1.7)
pywin32 (218)
rsa (3.1.4)
setuptools (5.4.1)
virtualenv (1.11.6)
wheel (0.24.0)
What's causing my error?