Learn Python the Hard Way Exercise 46: Installing Python packages (pip, nose etc.) on Windows

为君一笑 提交于 2019-12-05 20:27:20
Avensky

I had the same error but the answer was in the book. Type this into powershell, hope it works for you too.

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")

Try this:

// make sure you have pip and virtualenv installed
cd project
// create a virtual environment
virtualenv venv --distribute
// activate the virtual environment 
// I'm not 100% sure, but I think this is correct way on windows
venv\Scripts\activate.bat
// install nose
pip install nose

You should now be able to run nosetests as long as your virtualenv is activated.

Maybe this is late for your question, but this may help others that will experience the same issue that we've experienced. I've got mine working doing the ff. steps:

(Assuming that you've downloaded all packages as discussed in the book):

  1. pip from https://bootstrap.pypa.io/get-pip.py (save that as python file)
  2. distribute from http://pypi.python.org/pypi/distribute
  3. nose from http://pypi.python.org/pypi/nose/
  4. virtualenv from http://pypi.python.org/pypi/virtualenv

Follow this to install all:

  • Run Windows Powershell as Administrator
  • cd C:\Path_Where_You_Downloaded_get-pip.py
  • Install pip by using the command 'python get-pip.py'
  • Run Command Prompt as Administrator
  • cd to location of Python27 scripts (in my case C:\Python27\Scripts)
  • Try to update pip using the command 'pip install --upgrade pip'
  • Install Nose by using this command 'pip install C:\Path_Where_You_downloaded_nose'
  • Install distribute using command 'pip install distribute'

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!