我一直在主要在我的Mac上开发应用程序,现在我正在尝试 在Windows机器上设置开发环境。应用程序文件位于 所以我开始使用virtualenv,安装得很好:
<extracted virtualenv-1.10.1.tar.gz>
cd virtualenv-1.10.1
C:\Python27\python.exe setup.py install
我导航到我的应用程序开发文件夹并运行了开发命令:
(env) C:\Users\eclaird\work\MyApplication>python setup.py develop
这似乎运行得很好,依赖安装和所有:
running develop
running egg_info
writing requirements to MyApplication.egg-info\requires.txt
writing MyApplication.egg-info\PKG-INFO
writing top-level names to MyApplication.egg-info\top_level.txt
writing dependency_links to MyApplication.egg-info\dependency_links.txt
reading manifest file 'MyApplication.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'rpm\*.json'
warning: no previously-included files matching 'dev_*' found under directory 'MyApplication'
writing manifest file 'MyApplication.egg-info\SOURCES.txt'
running build_ext
Creating c:\users\eclaird\work\env\lib\site-packages\MyApplication.egg-link (link to .)
Adding MyApplication 1.2.30 to easy-install.pth file
Installing MyApplication-do-stuff.py script to C:\Users\eclaird\work\env\Scripts
Installed c:\users\eclaird\work\MyApplication
Processing dependencies for MyApplication==1.2.30
[... snip ...]
Finished processing dependencies for MyApplication==1.2.30
但是当我尝试运行应用程序脚本时出现此错误:
(env) C:\Users\eclaird\work\MyApplication>MyApplication-do-stuff.py -c dev-config.json
Traceback (most recent call last):
File "C:\Users\eclaird\work\env\Scripts\MyApplication-do-stuff.py", line 4, in <module>
from pkg_resources import require; require('MyApplication==1.2.30')
File "build\bdist.win-amd64\egg\pkg_resources.py", line 2793, in <module>
File "build\bdist.win-amd64\egg\pkg_resources.py", line 673, in require
File "build\bdist.win-amd64\egg\pkg_resources.py", line 576, in resolve
pkg_resources.DistributionNotFound: MyApplication==1.2.30
这些相同的步骤在我的Mac上运行良好。这有什么问题?
答案 0 :(得分:0)
我忘记了shebangs在Windows上什么都不做,所以运行MyApplication-do-stuff.py
脚本实际上是由系统范围的Python安装来处理的。这当然意味着你不会从虚拟环境中获得任何软件包,也不会从我的问题中得到模糊的错误。像这样运行脚本似乎有效:
(env) C:\Users\eclaird\work\MyApplication>python ..\env\Scripts\MyApplication-do-stuff.py - -c dev-config.json