简体   繁体   English

无法安装 Windows 的 python 诅咒模块

[英]python curses module for windows can't install

i try to install curses module on windows and it ends with this error我尝试在 Windows 上安装 Curses 模块并以这个错误结束

picture: https://i.stack.imgur.com/fbKCJ.png图片: https : //i.stack.imgur.com/fbKCJ.png

You can't install windows curses with 3.10 yet.您还不能在 3.10 中安装 windows curses。 It is supported on 3.9.它在 3.9 上受支持。 I don't know when it will be supported for 3.10, so your best option for now is just to install 3.9.我不知道什么时候会支持 3.10,所以你现在最好的选择就是安装 3.9。

You can make a virtual environment with python 3.9 for any projects that need to use curses.对于需要使用curses的任何项目,您都可以使用python 3.9创建虚拟环境。 A virtual environment makes a copy of your python interpreter and installs it into a directory of your choice.虚拟环境会复制您的 Python 解释器并将其安装到您选择的目录中。 You use this by "activating" the virtual environment, and as long as you're inside that environment, anything you install will be contained by this copied installation.您可以通过“激活”虚拟环境来使用它,只要您在该环境中,您安装的任何内容都将包含在此复制安装中。

This allows you to run different versions of python, and it also allows you to install packages that you don't want cluttering up your main installation.这允许你运行不同版本的 python,它还允许你安装你不想让主安装混乱的包。 It's a good idea to use this for all projects that are going to need packages outside of the standard library (anything that you pip install ).将它用于所有需要标准库之外的包的项目(任何pip install )是一个好主意。

To make a virtual environment with your default interpreter, type:要使用默认解释器创建虚拟环境,请键入:

python -m venv <envname> where <envname> is whatever you want the environments directory to be called. python -m venv <envname>其中<envname>是您想要调用环境目录的任何内容。 This is usually env .这通常是env

So python -m venv env would install a fresh copy of your python 3.10 to a folder called env inside your current directory.因此, python -m venv env会将 python 3.10 的新副本安装到当前目录中名为 env 的文件夹中。

You activate this by typing .\\<envname>\\scripts\\activate You'll then get a prompt that has (<envname>) in front of it, which will let you know you're in that environment.您可以通过键入.\\<envname>\\scripts\\activate它。然后您会得到一个提示,在它前面有(<envname>) ,这会让您知道您处于该环境中。

You can leave that environment by typing deactivate .您可以通过输入deactivate离开该环境。

In order to use a different version, you have to run venv with the interpreter you want to use on the project.为了使用不同的版本,您必须使用要在项目中使用的解释器运行 venv。 So if you wanted to use python 3.9, it would be something like所以如果你想使用 python 3.9,它会像

"C:\\Program Files\\Python39\\python.exe" -m venv env depending on where you installed python 3.9. "C:\\Program Files\\Python39\\python.exe" -m venv env取决于你安装 python 3.9 的位置。 The directory I used is usually the default directory when installing for all users.我使用的目录通常是所有用户安装时的默认目录。

To more easily work with other versions on windows, I make batch files for each one and put them in a utils folder that's on my system path.为了更轻松地在 Windows 上使用其他版本,我为每个版本制作了批处理文件,并将它们放在系统路径上的 utils 文件夹中。 (I'll explain how to add a folder to the system path at the bottom if you don't know.) (如果你不知道,我会解释如何在底部的系统路径中添加一个文件夹。)

So make a file called python39.bat , and into that, put "C:\\Program Files\\Python39\\python.exe" %* .因此,创建一个名为python39.bat的文件,然后在其中放入"C:\\Program Files\\Python39\\python.exe" %* (Or wherever the installation is. %* just expands other arguments so you can use it exactly like you would the other executable. (或者安装在哪里。 %*只是扩展其他参数,这样你就可以像使用其他可执行文件一样使用它。

That way you can create a new python 3.9 virtual environment with python39 -m venv env (along with any other arguments you want) instead of typing out the full path.这样您就可以使用python39 -m venv env (以及您想要的任何其他参数)创建一个新的 python 3.9 虚拟环境,而不是输入完整路径。

You can also use --prompt to change the name displayed by your virtual environment instead of changing the name of the folder.您还可以使用--prompt更改虚拟环境显示的名称,而不是更改文件夹的名称。 This is useful for making it shorter or just keeping things straight when you're using a bunch of environments for different projects.当您为不同的项目使用一堆环境时,这对于使其更短或只是保持简单很有用。 (Using the same folder name allows you have something that doesn't change into your standard ignore files.) (使用相同的文件夹名称允许您拥有不会更改为标准忽略文件的内容。)

So anyway, here's an example of the full process after you install python 3.9.所以无论如何,这是安装python 3.9后完整过程的示例。

  1. Go to your project directory or wherever you'd like to install the environment.转到您的项目目录或您想要安装环境的任何位置。
  2. type "C:\\Program Files\\Python39\\python.exe" -m venv env (optional) --prompt somealternatenametodisplay (or python39 -m venv env if you made a .bat file).输入"C:\\Program Files\\Python39\\python.exe" -m venv env (optional) --prompt somealternatenametodisplay (或者python39 -m venv env如果你制作了一个 .bat 文件)。
  3. type .\\env\\scripts\\activate输入.\\env\\scripts\\activate
  4. You should now have (env) or the alternate name at the beginning of your prompt您现在应该在提示开头有 (env) 或备用名称
  5. type pip install windows-curses输入pip install windows-curses

And everything should work now.现在一切都应该有效了。 Just remember to activate your environment whenever you want to use this.只要记住在您想使用它时激活您的环境。

(To put a folder on the path) Let's make a new folder called myutils as an example at C:\\myutils and put python39.bat in that folder. (在路径上放置一个文件夹)让我们在C:\\myutils处创建一个名为myutils的新文件夹作为示例,并将python39.bat放在该文件夹中。

  1. Right click My Computer右键单击My Computer
  2. Select properties选择properties
  3. On the right side under Related settings click on Advanced system settings.Related settings下的右侧,单击高级系统设置。
  4. At the bottom of the Advanced tab, click on Environment Variables (You can also get to Environment Variables much faster by opening the start menu and starting to type environment , which should give you Edit the system environment variables ).在“ Advanced选项卡的底部,单击“ Environment Variables (您还可以通过打开开始菜单并开始键入environment来更快地进入环境变量,这应该会让您Edit the system environment variables )。
  5. Under System variables , select Path , and then click Edit...System variables ,选择Path ,然后单击Edit...
  6. Type C:\\myutils , hit Enter , and press OK.键入C:\\myutils ,按Enter ,然后按 OK。

Now, open a new terminal, and you'll be able to access any programs you put in that folder.现在,打开一个新终端,您将能够访问您放在该文件夹中的任何程序。

In your path variable in Environment Variables , you can also change the default python interpreter.Environment Variables path变量中,您还可以更改默认的 python 解释器。 The default will be whichever one is at the top (which will probably be 3.9 now that you've just installed it).默认值将是顶部的任何一个(现在您刚刚安装它可能是 3.9)。

To change it back to 3.10, select C:\\Program Files\\Python310\\Scripts\\ and click Move Up until it's above the Python39 entries, then do the same with C:\\Program Files\\Python310\\ .要将其改回 3.10,请选择C:\\Program Files\\Python310\\Scripts\\并单击Move Up直到它位于 Python39 条目上方,然后对C:\\Program Files\\Python310\\执行相同操作。

GO to this URL and find your python version and download wheel file from it转到此URL并找到您的 python 版本并从中下载轮文件

As from my image it is python 3.7 with 64 bit so i will download this file windows_curses-2.2.0-cp37-cp37m-win_amd64.whl and give whole path where it is downloaded从我的图像来看,它是 64 位的 python 3.7,所以我将下载此文件windows_curses-2.2.0-cp37-cp37m-win_amd64.whl并提供下载它的完整路径

在此处输入图片说明

and give full path for installation like并提供完整的安装路径,如

pip install filepath\\windows_curses-2.2.0-cp37-cp37m-win_amd64.whl in cmd or powershell pip install filepath\\windows_curses-2.2.0-cp37-cp37m-win_amd64.whl在 cmd 或 powershell

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

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