简体   繁体   English

在cygwin中安装python模块

[英]Install python modules in cygwin

What is a way to instaill python modules within cygwin? 什么是在cygwin中实现python模块的方法? I'm new to cygwin and couldn't find pip or anything like that in the setup.exe package. 我是cygwin的新手,在setup.exe包中找不到pip或类似的东西。 I've looked around and I can't find a definitive way to do it. 我环顾四周,找不到明确的方法。 Does anyone have advice? 有人有建议吗?

On windows, under cygwin follow the below steps. 在Windows上,在cygwin下面按照以下步骤操作。

1.Ensure python is installed in cygwin. 1.Ensure python安装在cygwin中。 Type python on the terminal of cygwin and it should launch the python shell. 在cygwin的终端上键入python,它应该启动python shell。 If it doesn't launch the setup file for cygwin and select python from the package list and install. 如果它没有启动cygwin的安装文件并从包列表中选择python并安装。 2. Now, install pip if it's not already installed. 2.现在,如果尚未安装pip,请安装它。 Provide full path if you have multiple python installations eg 如果您有多个python安装,请提供完整路径,例如

/usr/bin/python2.7 -m ensurepip
/usr/bin/python3.6 -m ensurepip

3. Now, you can use pip to install the python package. 3.现在,您可以使用pip来安装python包。 Depending upon the installation in which you want the package to be installed, run below command(s) 根据您希望安装软件包的安装,运行以下命令

/usr/bin/python2.7 -m pip install pyyaml
/usr/bin/python3.6 -m pip install pyyaml

In standard python installation, pip like scripts goes under " your_python_directory \\Scripts". 在标准的python安装中,像pip一样的脚本位于“ your_python_directory \\ Scripts”下。 (in my system C:\\Python34\\Scripts) Make sure you have added this path to system directories (Environment Variables). (在我的系统C:\\ Python34 \\ Scripts中)确保已将此路径添加到系统目录(环境变量)。 Then 然后

pip.exe install my_package_name

will work fine. 会很好的。

Also for configuring within cygwin this will help. 也为cygwin的内配置会有所帮助。

PS: sorry for confusion though I thought you meant you have installed python separately from cygwin. PS:抱歉混淆虽然我以为你的意思是你已经从cygwin中分别安装了python。 I believe this thread answers your question. 我相信这个帖子可以回答你的问题。

I would suggest installing the python in windows. 我建议在Windows中安装python。

Suppose you install the python in D drive, then just call the installed python from cygwin like 假设你在D盘中安装python,然后从cygwin中调用已安装的python

/cygdrive/d/Python37/python.exe

In this case, you would not get two versions of python (one in cygwin, one in windows). 在这种情况下,你不会得到两个版本的python(一个在cygwin中,一个在windows中)。 And you can call the python from other terminals as well. 你也可以从其他终端调用python。

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

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