简体   繁体   中英

activating python venv from bash in Windows. How to resolve problem with line endings?

I have a bash script to deploy some code to AWS. It mostly works but I'm having issues activating my virtual environment. It seems it might be to do with line endings because I'm trying to activate a windows venv using Scripts/activate.

I see these types of errors in the logs:

Scripts/activate: line 3: $'\\r': command not found Scripts/activate: line 4: $'\\r': command not found Scripts/activate: line 10: syntax error near unexpected token `$'{\\r''

My script creates, installs packages then destroys the venv. If I comment out the creating and destroy and change the line endings of the activate script to 'LF' it works. So How can I force LF endings instead of CRLF on virtual env creation?

This is the line that is creating the env at the moment: virtualenv $VENV

fixed with dos2unix command

dos2unix Scripts/activate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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