I've tried everything I can but now I need help! I've hit the limit of what I do understand.
My error:
My take is that virtualenv doesn't know where python is. Is this the case? How can I fix this?
System is Mac OSX 10.9.4
I have used brew to install python 2.7.8.1. - Python 2.7*something* was on there but I removed it. I can't remember exactly what I did to do that however. Sorry. I am new to macs. - This new python instance sits here: /usr/local/Cellar/python/2.7.8_1/
- The /usr/local/bin/python
file when I readlink /usr/local/bin/python it points to the above
.bash_profile:
Paths:
Python seems to work but path looks busy
Any help appreciated!
Thanks,
Andy
This is going badly... Help! Not least because I have messed up the links, I think there is a problem with these links
I thought I had it. I changed the links as follows. But it's still screwed.
I'd better stop now before I do any more damage.
I changed /usr/bin/python to point to /usr/local/Cellar/python/2.7.8_1/bin python2.7:
No the error has evolved to the below:
1 Answer
Resolved as follows:
- System restore by downloading and re-installing Maverics (using the automated apple startup tool)
- Following the advice here: Can't pip install virtualenv in OS X 10.8 with brewed python 2.7 and here:http://www.lowindata.com/2013/installing-scientific-python-on-mac-os-x/
- My virtualenv was in a different location to that specified in page (2), so bash_profile should containsource /usr/local/bin/virtualenvwrapper.shinstead of:source /usr/local/share/python/virtualenvwrapper.sh
Not the answer you're looking for? Browse other questions tagged pythonpython-2.7osx-mavericksvirtualenvvirtualenvwrapper or ask your own question.
I've created a bash script but when I try to execute it, I get
I need to run the command: bash script.sh
for it to work.
How can I fix this?
8 Answers
This kind of message is usually due to a bogus shebang line, either an extra carriage return at the end of the first line or a BOM at the beginning of it.
Run:
and see how it ends.
This is wrong:
Antamedia hotspot software - hotspot billing wifi software. This is wrong too:
This is correct:
Use dos2unix
(or sed
, tr
, awk
, perl
, python
…) to fix your script if this is the issue.
Here is one that will remove both of a BOM and tailing CRs:
Note that the shell you are using to run the script will slightly affect the error messages that are displayed.Here are three scripts just showing their name (echo $0
) and having the following respective shebang lines:
correctScript:
Key_load_public: No Such File Or Directory
scriptWithBom:
scriptWithCRLF:
Under bash, running them will show these messages:
Running the bogus ones by explicitely calling the interpreter allows the CRLF script to run without any issue:
Here is the behavior observed under ksh
:
and under dash
:
This can also be caused by a BOM in a UTF-8 script. If you create the script in Windows sometimes you get some junk at the start of the file.
Actualy, the right shebang for bash script is this:
Because, in freeBSD, bash is located in /usr/local/bin/bash
You can use vi to fix both problems if they exist:
If you don't have dos2unix this is a way to fix this issue.
This could be caused by a BOM. From Wikipedia, a BOM is a
The byte order mark (BOM) is a Unicode character, U+FEFF byte order mark (BOM), whose appearance as a magic number at the start of a text stream can signal several things to a program consuming the text
Unfortunately, it doesn't signal anything to the Linux kernel that handles the she-bang line. You can verify you have a BOM by using file
,
Or you can hexdump the first few characters and see if they match any of the BOM characters manually
You can strip the BOM characters once you know them like this,
I had the issue by accidentally adding a wrong bash executable to the PATH
and because in my script the more flexible #!/usr/bin/env bash
shebang was used (take first bash executable from path).
I have installed GIT for Windows to work in cygwin
together with Windows GIT GUIs (was not working with cygwin native git..). I solved this now by switching to #!/bin/bash
sheband and removing GIT for windows from PATH
.
Try #!/bin/bash
Second thing: find / -name bash
Third thing: ls -al /bin/bash
protected by Community♦Oct 31 '18 at 13:23
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged bashshell-scriptexecutableshebang or ask your own question.
- -bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
- Traceback (most recent call last):
- File '/usr/lib/python3.4/site.py', line 586, in <module>
- File '/usr/lib/python3.4/site.py', line 572, in main
- File '/usr/lib/python3.4/site.py', line 287, in addusersitepackages
- File '/usr/lib/python3.4/site.py', line 263, in getusersitepackages
- user_base = getuserbase() # this will also set USER_BASE
- File '/usr/lib/python3.4/site.py', line 253, in getuserbase
- File '/usr/lib/python3.4/sysconfig.py', line 597, in get_config_var
- File '/usr/lib/python3.4/sysconfig.py', line 540, in get_config_vars
- File '/usr/lib/python3.4/sysconfig.py', line 412, in _init_posix
- File '/usr/lib/python3.4/_sysconfigdata.py', line 6, in <module>
- ImportError: No module named '_sysconfigdata_m'