我正在使用计算群集,但无法访问整个群集。因此,我试图在本地(“主”目录中)安装python软件包,但是从脚本导入它们时遇到了问题。
我尝试更新PATH和PYTHONPATH,并将它们都设置为〜/ .local / lib。我要导入的集群上已经创建了一个python 3.7.3模块。但是我无权为其添加更多软件包,这就是为什么我必须在本地安装。模块的路径和我的.local目录都在PATH中。
当我使用pip安装软件包时,出现以下错误:“错误:由于EnvironmentError而无法安装软件包:[Errno 13]权限被拒绝:'/ s1 / opt / python-3.7.3 / lib / python3 .7 / site-packages / numpy'
考虑使用--user
选项或检查权限。“因此,我必须在本地安装它。当我使用--user
选项时,一切似乎都可以正常安装。此外,我的python3.7版本本地目录只有python和site-packages目录,而集群模块中的python3.7还有很多其他文件。
安装这些软件包后,当我转到脚本并尝试运行它们时,会出现这些错误。
Traceback (most recent call last):
File "fragment_assignment.py", line 10, in <module>
import numpy as np
File "/s1/snagaraj/.local/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/s1/snagaraj/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 71, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
1. Check that you are using the Python you expect (you're using /usr/bin/python),
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy versions you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
最初的错误是:
没有名为_multiarray_umath的模块
请注意,所有向我提出错误的人提出的所有修补程序都不适用于我。
答案 0 :(得分:0)
我建议为您的应用程序/开发需求创建一个virtual environment,然后在其中运行。通常,虚拟环境是确保您拥有所需的所有依赖项并且不会与其他事物发生冲突的好方法。大概最简单的方法是使用pipenv
。 Another article on virtual environments and pipenv。
要开始,请确保已安装constepxr operator size_t()
:
pipenv
为您的项目创建一个文件夹,然后将目录更改为该文件夹(或仅将$ pip install --user pipenv
更改为当前项目目录):
cd
然后从$ mkdir my_project
$ cd my_project
目录中开始安装所需的软件包:
my_project
或您需要的任何软件包。该操作完成后,您可以通过运行以下命令来激活环境:
$ pipenv install numpy scipy pandas
,然后使用python进行任何操作。另外,您可以使用以下命令在环境中运行脚本(我们将其称为$ pipenv shell
)
my_script.py
答案 1 :(得分:0)
似乎某处可能缺少依赖项。尝试安装libatlas3-base来获取该文件。
sudo apt-get install libatlas3-base