#๐Ÿ”’ Help with Python Packages

42 messages ยท Page 1 of 1 (latest)

cedar geode
#

I get this warning when importing pandas

NumPy 2.0.2 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.```
noble hollowBOT
#

@cedar geode

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cedar geode
#
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\__init__.py", line 80, in <module>
    from pandas.core.api import (
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\api.py", line 28, in <module>
    from pandas.core.arrays import Categorical
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\arrays\__init__.py", line 1, in <module>
    from pandas.core.arrays.arrow import ArrowExtensionArray
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\arrays\arrow\__init__.py", line 5, in <module>
    from pandas.core.arrays.arrow.array import ArrowExtensionArray
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\arrays\arrow\array.py", line 50, in <module>
#
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\ops\__init__.py", line 8, in <module>
    from pandas.core.ops.array_ops import (
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\ops\array_ops.py", line 56, in <module>
    from pandas.core.computation import expressions
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\computation\expressions.py", line 21, in <module>
    from pandas.core.computation.check import NUMEXPR_INSTALLED
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\computation\check.py", line 5, in <module>
    ne = import_optional_dependency("numexpr", errors="warn")
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\compat\_optional.py", line 135, in import_optional_dependency
    module = importlib.import_module(name)
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\blade\AppData\Local\Programs\Python\Python39\lib\site-packages\numexpr\__init__.py", line 24, in <module>
    from numexpr.interpreter import MAX_THREADS, use_vml, __BLOCK_SIZE1__
AttributeError: _ARRAY_API not found```
gaunt moat
cedar geode
#

I think it has to do with pip and some package I have installed not being compatable but I have no idea what it could be

#

Also I don't want to downgrade numpy. My current version of numpy is what I want, I just don't know what's conflicting

gaunt moat
#

Please provide your pip list/pip freeze

cedar geode
#

I don't know if I can post it in the channel, my pip freeze is really massive

gaunt moat
#

I'm most interested in versions of numpy and numexpr.
Because the last lines of traceback suggest it's something in numexpr

cedar geode
#

Nope

#

Yeah I've figured out that I probably should have been using venvs for the past like 6 years...

unborn drum
#

I think it's pandas

#

I've seen this error a lot and it's usually pandas+numpy conflicting

gaunt moat
cedar geode
#

I kinda do too, but I've force reinstalled pandas multiple times, and it hasn't fixed this

gaunt moat
cedar geode
#

the latest

gaunt moat
#

Again, please provide version of pandas and numexpr

cedar geode
#
pandas==2.2.3
numexpr==2.8.4
numpy==2.0.2```
gaunt moat
unborn drum
#

Wonder why pandas install didn't update that one

cedar geode
#

I'm gonna be honest this python installation on my computer is absolutely messed up

unborn drum
#

If you pip install pandas[performance] it might fix it

gaunt moat
gaunt moat
noble hollowBOT
#
Virtual environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
gaunt moat
#

Although it would be better to grab newer python and start fresh

#

3.9 is currently lowest still supported version

#

So next year it will reach its end of life

cedar geode
#

Yeah I know, my python is absolutely ancient now

#

Also updating numexpr fixed the issue! So thank you to both of you!

cedar geode
#

Thanks!

#

!close

noble hollowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.