简体   繁体   English

如何从 Linux 控制台运行 Python 模块?

[英]How to run a Python module from Linux console?

I am a beginner in Linux and I am trying to do something very basic (yet it does not seem to work).我是 Linux 的初学者,我正在尝试做一些非常基本的事情(但它似乎不起作用)。

I have installed a python3 package. I wish to run this Python package on a specific folder from my linux machine.我已经安装了 python3 package。我希望在我的 linux 机器的特定文件夹上运行这个 Python package。 The idea is that this package should restructure all my files in a specific format (this is the link to the package https://github.com/SIMEXP/Data2Bids ).这个想法是这个 package 应该以特定格式重组我的所有文件(这是指向 package https://github.com/SIMEXP/Data2Bids的链接)。

In the demo of the tutorial, it is mentioned that once I install the package:在教程的演示中,提到一旦我安装了 package:

pip3 install data2bids

I should just use cd on my desired folder that needs restructuring and then simply run data2bids .我应该只在需要重组的所需文件夹上使用cd ,然后简单地运行data2bids

After doing so, I received a command not found error.这样做之后,我收到一个command not found错误。

I have tried to run the package using the python data2bids command (thinking that maybe I should mention it is a python package. I have tried to use the full path of where the package was installed in the command, yet it did not work. I even tried to install the package in the same folder as my directory that needs restructuring, with no results.我尝试使用python data2bids命令运行 package(想也许我应该提到它是 python package。我尝试使用命令中安装 package 的完整路径,但它没有用。我甚至尝试将 package 安装在与我需要重组的目录相同的文件夹中,但没有结果。

I believe that this is a very basic problem, and the solution may be very simple.我相信这是一个非常基本的问题,解决方案可能也很简单。 Within a linux machine, how does one exactly run a python module in a specific folder?在 linux 机器中,如何在特定文件夹中准确运行 python 模块?

I am also a rookie in Linux, here's what i can think of.我也是Linux的菜鸟,能想到的就到这里了。

First, the input is:首先,输入是:

A directory containing some files in any extension, with names containing at minimum the information of modality and patient number.包含任何扩展名的一些文件的目录,其名称至少包含模态和患者编号的信息。 A.JSON configuration file explaining how the filenames should be read. A.JSON 配置文件,说明应如何读取文件名。

I assume you ran the command without the configuration file.我假设您在没有配置文件的情况下运行了命令。

Second, Linux has built-in python whose version is 2.x, try to type python in command line and print python version, if it's 3.x, try to query pip installed list to see if the package was installed successfully, if not, see if the installed python 3.x directory is contained in PATH.二、Linux内置python,版本为2.x,尝试在命令行输入python,打印python版本,如果是3.x,则尝试查询pip安装列表,看883731838是否安装成功, ,查看PATH中是否包含安装的python 3.x目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM