Python Forum

Full Version: Pandas module not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I recently got a new computer I installed python v 3.10 and am using the pycharm IDE.

I have installed pandas but it is not working.

I am getting this error message everytime I run the code.

Traceback (most recent call last):
  File "C:\Users\Hass\Desktop\test\K-Means.py", line 7, in <module>
    import pandas as pd
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\__init__.py", line 48, in <module>
    from pandas.core.api import (
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\core\api.py", line 29, in <module>
    from pandas.core.arrays import Categorical
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\core\arrays\__init__.py", line 11, in <module>
    from pandas.core.arrays.interval import IntervalArray
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\core\arrays\interval.py", line 90, in <module>
    from pandas.core.indexes.base import ensure_index
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\core\indexes\base.py", line 143, in <module>
    from pandas.core.arrays.sparse import SparseDtype
  File "C:\Users\Hass\Desktop\test\venv\lib\site-packages\pandas\core\arrays\sparse\__init__.py", line 3, in <module>
    from pandas.core.arrays.sparse.accessor import (
ValueError: source code string cannot contain null bytes
Any help in resolving this issue will be appreciated.
How did you install pandas? What is the OS?
Hass Wrote:Desktop\test\venv
Are you aware of that now run from a virtual environment(venv)❓
That's ok but you have to install to environment an test hat it work there.
Look at Configure a Python interpreter.
PyCharm dos a lot of automatic setup like make a virtual environment,but you should(i would say most) learn to also to this from command line.
Here a quick run.
# Test version 
G:\div_code
λ python -V
Python 3.10.4

G:\div_code
λ pip -V
pip 22.0.4 from C:\Python310\lib\site-packages\pip (python 3.10)

# Path to executable used in virtual enviroment the Path will be different
G:\div_code
λ python -c "import sys; print(sys.executable)"
C:\python310\python.exe

# Test that pandas work
G:\div_code
λ python
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
>>> pandas.__version__
'1.4.1'
>>> exit()
So here i have Pandas install to default Python version,if work like this can choice Setting an existing Python interpreter.
This is normal starting point as most new users install to there default Python version with pip install pandas.
I have seen sevral times with new PyChram users,that the don't that virtual environment is automatic created.
I don't use PyChram,just obversions of Thread we have gotten here.