pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.83k stars 1.03k forks source link

UnboundLocalError using -p option on Windows #750

Closed NiklasRosenstein closed 5 years ago

NiklasRosenstein commented 9 years ago

When I use the -p option, I get UnboundLocalError: local variable 'original_python' referenced before assignment

C:\Users\niklas\Desktop\stack>virtualenv env -p "C:\maxon\Cinema 4D R15 Dev\resource\modules\python\res\Python.win64.framework\python.exe" --no-site-packages
Running virtualenv with interpreter C:\maxon\Cinema 4D R15 Dev\resource\modules\python\res\Python.win64.framework\python.exe
Overwriting env\lib\site.py with new content
New python executable in env\Scripts\python.exe
Traceback (most recent call last):
  File "F:\Python27\lib\site-packages\virtualenv.py", line 2352, in <module>
    main()
  File "F:\Python27\lib\site-packages\virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "F:\Python27\lib\site-packages\virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "F:\Python27\lib\site-packages\virtualenv.py", line 1363, in install_python
    shutil.copy(original_python, py_executable)
UnboundLocalError: local variable 'original_python' referenced before assignment

The referenced Python version is 2.6.4, using virtualenv 12.1.1

NiklasRosenstein commented 9 years ago

I just tried installing virtualenv to the Python installation that I passed via -p, but I get the same error. It seems to be a problem with Python 2.6?

NiklasRosenstein commented 9 years ago

No the problem is the .framework in the path. See L1351-L1364.

NiklasRosenstein commented 9 years ago

Please take a look at my fix at https://github.com/NiklasRosenstein/virtualenv/commit/b3c5b58cf7c95bb093a6d70070e2ad2d7fed8237. I simply initialized original_python with None, and if it is still None after the 'EDP' and 'Python.framework' things are checked, the code below is not executed.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.