You are not logged in.

#1 2024-05-16 22:41:52

ElMastro
Member
Registered: 2015-12-02
Posts: 64

[SOLVED] Python behave strangely in Pydev

Greetings,
I have used Pydev on eclipse IDE for some time. At a certain point, when I run the scripts, importing pandas with python results in

Traceback (most recent call last):
  File "/home/maxtro/Projects/Searcher/Main/Main_playwright.py", line 1, in <module>
    import pandas as pd        #scrivere    csv
    ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pandas/__init__.py", line 11, in <module>
    __import__(_dependency)
  File "/home/maxtro/.local/lib/python3.11/site-packages/numpy/__init__.py", line 141, in <module>
    from . import core
  File "/home/maxtro/.local/lib/python3.11/site-packages/numpy/core/__init__.py", line 9, in <module>
    from numpy.version import version as __version__
  File "/home/maxtro/.local/lib/python3.11/site-packages/numpy/version.py", line 3, in <module>
    from ._version import get_versions
  File "/home/maxtro/.local/lib/python3.11/site-packages/numpy/_version.py", line 7, in <module>
    import json
  File "/usr/lib/python3.12/json/__init__.py", line 106, in <module>
    from .decoder import JSONDecoder, JSONDecodeError
  File "/usr/lib/python3.12/json/decoder.py", line 3, in <module>
    import re
  File "/usr/lib/python3.12/re/__init__.py", line 141, in <module>
    @enum.global_enum
     ^^^^^^^^^^^^^^^^
AttributeError: module 'enum' has no attribute 'global_enum'

This thing is odd, as if I import pandas in a regular Python shell it works without problems.
I have tried to google it, but I found nothing.
I tried to change the Python interpreter in the settings, nothing seems to work.
If I comment the first line, same error happens with numpy.

Thank you in advance!

Last edited by ElMastro (2024-05-18 23:05:32)

Offline

#2 2024-05-16 23:02:47

zdislavo
Member
From: uk halifax
Registered: 2024-05-13
Posts: 43
Website

Re: [SOLVED] Python behave strangely in Pydev

Update Libraries

1 Activate your Python environment and update pandas and numpy.

pip install --upgrade pandas numpy

2 reinstall Libraries for the Correct Python Version

If you have libraries installed for Python 3.11 but are running Python 3.12, reinstall them specifically for Python 3.12.

# First, ensure you are using Python 3.12
python3.12 -m venv myenv
source myenv/bin/activate

# Reinstall pandas and numpy
pip install pandas numpy

3 Clear Cached Compiled Files

find . -type d -name "__pycache__" -exec rm -r {} +
find . -type f -name "*.pyc" -exec rm -r {} +

Offline

#3 2024-05-18 23:05:01

ElMastro
Member
Registered: 2015-12-02
Posts: 64

Re: [SOLVED] Python behave strangely in Pydev

First of all,
thank for your help zdslavo, I really appreciate it.

Unfortunately I tried all the things you suggested but nothing worked.
On the other hand, I followed your reasoning, and In Preferences I changed the order of the libraries in the Python interpreter.
[img=https://i.postimg.cc/tgdSrFDD/screenshot.png]Preferences[/img]
And now it restarted to work again.
This must depend on my poor comprehension of how this software works.

Have a nice day! smile

Last edited by ElMastro (2024-05-18 23:06:08)

Offline

#4 2024-07-21 17:15:14

zdislavo
Member
From: uk halifax
Registered: 2024-05-13
Posts: 43
Website

Re: [SOLVED] Python behave strangely in Pydev

try Spyder

Spyder is a free and open source scientific environment for Python. It combines advanced editing, analysis, debugging, and profiling, with data exploration

Offline

#5 2024-07-21 19:27:51

mithrial
Member
Registered: 2017-03-05
Posts: 12

Re: [SOLVED] Python behave strangely in Pydev

You are not using a venv or have messed up the search paths. It is loading packages from 3.11 from your user-local packages and also 3.12 modules from the sys path.

Offline

Board footer

Powered by FluxBB