代码之家  ›  专栏  ›  技术社区  ›  asmgx

无法在Linux中安装pandas

  •  0
  • asmgx  · 技术社区  · 3 年前

    我正试图在我的大学服务器上运行我的python代码(它的操作系统是Linux)

    当我尝试运行我的代码时,我得到了这个错误

    [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'
    

    我意识到Pandas尚未安装

    所以我试着安装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'
    

    我试着谷歌一下

    谷歌建议pip先安装wheel

    [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'
    

    我想知道这个问题有什么解决办法吗?

    2 回复  |  直到 3 年前
        1
  •  1
  •   Divyanshu Srivastava    3 年前

    我想你可能想用 --user 旗帜

    pip3 install --user pandas
    

    这将在您的用户帐户中安装pandas,而不是全局python安装(需要sudo权限)。

    Read mode here

        2
  •  0
  •   asmgx    3 年前

    我找到了答案

    问题是我必须安装 cython numpy 第一

    pip3 install -v --no-binary :all: --user cython
    pip3 install -v --no-binary :all: --user numpy
    pip3 install -v --no-binary :all: --user pandas