You are not logged in.
I have installed from repository :
- python-numpy 2.1.1-1
- python-tensorflow 2.17.0-2
- tensorflow 2.17.0-2
When I try to import TensorFlow, I get the following error:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/lib/python3.12/site-packages/ipykernel_launcher.py", line 18, in <module>
app.launch_new_instance()
File "/usr/lib/python3.12/site-packages/traitlets/config/application.py", line 1075, in launch_instance
app.start()
File "/usr/lib/python3.12/site-packages/ipykernel/kernelapp.py", line 739, in start
self.io_loop.start()
File "/usr/lib/python3.12/site-packages/tornado/platform/asyncio.py", line 205, in start
self.asyncio_loop.run_forever()
File "/usr/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
self._run_once()
File "/usr/lib/python3.12/asyncio/base_events.py", line 1986, in _run_once
handle._run()
File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 545, in dispatch_queue
await self.process_one()
File "/usr/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 534, in process_one
await dispatch(*args)
File "/usr/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 437, in dispatch_shell
await result
File "/usr/lib/python3.12/site-packages/ipykernel/ipkernel.py", line 362, in execute_request
await super().execute_request(stream, ident, parent)
File "/usr/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 778, in execute_request
reply_content = await reply_content
File "/usr/lib/python3.12/site-packages/ipykernel/ipkernel.py", line 449, in do_execute
res = shell.run_cell(
File "/usr/lib/python3.12/site-packages/ipykernel/zmqshell.py", line 549, in run_cell
return super().run_cell(*args, **kwargs)
File "/usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3075, in run_cell
result = self._run_cell(
File "/usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3130, in _run_cell
result = runner(coro)
File "/usr/lib/python3.12/site-packages/IPython/core/async_helpers.py", line 128, in _pseudo_sync_runner
coro.send(None)
File "/usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3334, in run_cell_async
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
File "/usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3517, in run_ast_nodes
if await self.run_code(code, result, async_=asy):
File "/usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "/tmp/ipykernel_51366/4197461287.py", line 7, in <module>
import tensorflow as tf
File "/usr/lib/python3.12/site-packages/tensorflow/__init__.py", line 46, in <module>
from tensorflow._api.v2 import __internal__
File "/usr/lib/python3.12/site-packages/tensorflow/_api/v2/__internal__/__init__.py", line 11, in <module>
from tensorflow._api.v2.__internal__ import distribute
File "/usr/lib/python3.12/site-packages/tensorflow/_api/v2/__internal__/distribute/__init__.py", line 8, in <module>
from tensorflow._api.v2.__internal__.distribute import combinations
File "/usr/lib/python3.12/site-packages/tensorflow/_api/v2/__internal__/distribute/combinations/__init__.py", line 8, in <module>
from tensorflow.python.distribute.combinations import env # line: 456
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/combinations.py", line 33, in <module>
from tensorflow.python.distribute import collective_all_reduce_strategy
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/collective_all_reduce_strategy.py", line 25, in <module>
from tensorflow.python.distribute import cross_device_ops as cross_device_ops_lib
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/cross_device_ops.py", line 28, in <module>
from tensorflow.python.distribute import cross_device_utils
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/cross_device_utils.py", line 22, in <module>
from tensorflow.python.distribute import values as value_lib
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/values.py", line 23, in <module>
from tensorflow.python.distribute import distribute_lib
File "/usr/lib/python3.12/site-packages/tensorflow/python/distribute/distribute_lib.py", line 205, in <module>
from tensorflow.python.data.ops import dataset_ops
File "/usr/lib/python3.12/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 34, in <module>
from tensorflow.python.data.ops import iterator_ops
File "/usr/lib/python3.12/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 45, in <module>
from tensorflow.python.training.saver import BaseSaverBuilder
File "/usr/lib/python3.12/site-packages/tensorflow/python/training/saver.py", line 50, in <module>
from tensorflow.python.training import py_checkpoint_reader
File "/usr/lib/python3.12/site-packages/tensorflow/python/training/py_checkpoint_reader.py", line 19, in <module>
from tensorflow.python.util._pywrap_checkpoint_reader import CheckpointReader
How can I solve this error?
Offline
same problem here...
I'm trying to use virtual envs now.
Offline
There is an issue for it: https://gitlab.archlinux.org/archlinux/ … /issues/11.
There was a discussion at tensorflow. I'm not a user, but was curious. The content of the issue might have more meaning to you.
Just a suggestion. There is a train of thought in the python world --- leave the system python environment alone and do application development in a virtual environment. This reduces the chances of negatively impacting the running system by isolating the projects' python environment. It also gives you the ability to easily roll-back or install a specific version of a module. In this case, the temporary fix seems to install a specific version of numpy, which can be done in a virtual environment.
A simple example of a Python virtual environment
# Make your project directory and change into it
cd $HOME
mkdir -p Projects/MyNewProject && cd Projects/MyNewProject
# Create virtual environment.
# Afterwards there will be a hidden directory, Projects/MyNewProject/.venv, where everything is installed.
# This will also be the first directory in $PATH.
python -m venv .venv
# activate/deactivate this specific python environment
source .venv/bin/activate
# Add modules to "requirements.txt".
pip install numypy==1.26.4
pip install tensorflow
pip install pip-review
# add as needed
# Install
pip install -r requirements.txt
NOTE: When I installed "tensorflow" using "pip" in a virtual environment, it uninstalled numpy 2.1.1 and installed numpy 1.26.4 automatically.
Links
- venv — Creation of virtual environments
- Python package search
- Python Virtual Environments: A Primer
Offline