0

I am trying to run my python code in my University server ( its OS is Linux)

When I try to run my code I get this error

[am333@uni-login-06 ~]$ python3 15Gadi01.py
Traceback (most recent call last):
  File "15Gadi01.py", line 1, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

I realised that Pandas is not installed

so I tried to install Pandas

[am333@uni-login-06 ~]$ pip3 install pandas
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/c3/e2/00cacecafbab071c787019f00ad84ca3185952f6bb9bca9550ed83870d4d/pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.15.4 (from pandas)
  Using cached https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting pytz>=2017.2 (from pandas)
  Using cached https://files.pythonhosted.org/packages/70/94/784178ca5dd892a98f113cdd923372024dc04b8d40abe77ca76b5fb90ca6/pytz-2021.1-py2.py3-none-any.whl
Collecting python-dateutil>=2.7.3 (from pandas)
  Using cached https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl
Requirement already satisfied: six>=1.5 in /half-root/usr/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas)
Installing collected packages: numpy, pytz, python-dateutil, pandas
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3.6/site-packages/pip/commands/install.py", line 365, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 789, in install
    **kwargs
  File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 854, in install
    strip_file_prefix=strip_file_prefix
  File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 1069, in move_wheel_files
    strip_file_prefix=strip_file_prefix,
  File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 287, in clobber
    ensure_dir(dest)  # common for the 'include' path
  File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/lib64/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/usr/local/lib64/python3.6'

I tried to google it

and google suggested pip install wheel first

[am333@guni-login-06 ~]$ pip3 install wheel
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Installing collected packages: wheel
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3.6/site-packages/pip/commands/install.py", line 365, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 789, in install
    **kwargs
  File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 854, in install
    strip_file_prefix=strip_file_prefix
  File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 1069, in move_wheel_files
    strip_file_prefix=strip_file_prefix,
  File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 287, in clobber
    ensure_dir(dest)  # common for the 'include' path
  File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/lib64/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/usr/local/lib/python3.6'

I wonder is thre is a solution to this problem?

asmgx
  • 7,328
  • 15
  • 82
  • 143
  • 2
    You are trying to install the package into the python directory itself. Unfortunately that path is in a read only position. I would suggest you to create a virtuall env in a non read onyl path and install what packages you want there. – leoOrion Apr 09 '21 at 03:53
  • Yes, it's a good idea to do all your python stuff in virtual environments. There are several `venv` wrappers, but you can check the py docs to get started: [pip and virtual environments](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) – tdy Apr 09 '21 at 04:09
  • 1
    See [pip install failing with: OSError: \[Errno 13\] Permission denied on directory](https://stackoverflow.com/questions/31512422/pip-install-failing-with-oserror-errno-13-permission-denied-on-directory). The error message is different, but the solution to most directory permission problems is the same: Use a virtual environment. – Gino Mempin Apr 09 '21 at 05:18

2 Answers2

1

I think you might wish to use the --user flag

pip3 install --user pandas

This will install pandas in your user account, instead of global python installation (which requires sudo privileges).

Read mode here

Divyanshu Srivastava
  • 1,379
  • 11
  • 24
0

I found the answer

The problem is that I have to install cython and numpy first

pip3 install -v --no-binary :all: --user cython
pip3 install -v --no-binary :all: --user numpy
pip3 install -v --no-binary :all: --user pandas
asmgx
  • 7,328
  • 15
  • 82
  • 143