my python does not work " -bash: */python: Invalid argument" - python

Suddenly my development server python does not work.
Error message is as follows:
root#scu4:~# python
-bash: /root/anaconda3/bin/python: Invalid argument
/root/anaconda3/bin/ is python installed directory.
How can I fix it?

this error is because its not opening python from directory in which its installed rather its opening from /root/anaconda3/bin/python and it requires some arguements.
you can try python -h or python --help
there can be a chance that after installing anaconda it might have upgraded to python 3.x version try
root#scu4:~#python3
might solve your problem.
If this doesnt help, sudo root and then run the following command : ls -lah /usr/bin | grep python it should produce some output if not python is relocated to someother directory.

If Anaconda is on docker stop the docker and start it again.
docker stop <container>
docker start <container>
docker attach <continer>
See this issue for details.

conda update -n base -c defaults conda
helped me.

Related

Error loading Python lib '/tmp/_MEIR5kRcn/libpython3.7m.so.1.0': dlopen: libcrypt.so.1 during running docker-compose

I am having this problem running Docker Compose on my machines. I have switched machines and the problem still persists.
Error Message:
[40335] Error loading Python lib '/tmp/_MEIR5kRcn/libpython3.7m.so.1.0': dlopen: libcrypt.so.1: cannot open shared object file: No such file or directory
My OS is fully updated.
I have tried the solutions listed here, here and here.
Here is the output of ldd --version.
ldd (GNU libc) 2.35
Docker itself is functioning as expected. Docker-compose, however, isn't. Trying to docker-compose up or docker-compose --version results in the error.
install libxcrypt-compat maybe helps
sudo pacman -S libxcrypt-compat
https://archlinux.org/packages/core/x86_64/libxcrypt-compat
I fix this issue by created a symbolic link from libcrypt.so to libcrypt.so.1
Link this: $ ln -s /usr/lib/libcrypt.so /usr/lib/libcrypt.so.1
Hope it's worked for you
This was my solution: delete directories ./build and ./dist and run pyinstaller again.
I noticed that if ./build already exists, Pyistaller will reuse the same ./build. Any previous issues in ./build will persist, sometimes with new error messages, because the directory was not recreated. Deleting ./build leads to a new ./build being created next time you run pyinstaller.
This was the original error I was getting.
$ ./name_of_executable_created_by_pyinstaller
[26645] Error loading Python lib '/tmp/_MEITnO6JV/libpython3.7m.so': dlopen: /tmp/_MEITnO6JV/libpython3.7m.so: cannot open shared object file: No such file or directory
I was running on manjaro. I had to remove docker-compose, install it back and symlink to it's actual location. I don't know if this works on other distros.
sudo rm $(which docker-compose)
Now install it back;
sudo pacman -S docker-compose
Finally create a symlink;
sudo ln -s /usr/bin/docker-compose /usr/local/bin/docker-compose
Confirm it's fine;
docker-compose --version

docker-compose up, bad interpreter, is looking for the wrong path for python executable

When I run docker-compose up
I get the error
zsh: /home/emil/.local/bin/docker-compose: bad interpreter: /home/linuxbrew/.linuxbrew/Cellar/python#2/2.7.16/bin/python: no such file or directory
I checked which python and I get
/home/linuxbrew/.linuxbrew/bin/python
I tried to system link
➜ 2.7.16 ln -s /home/linuxbrew/.linuxbrew/bin/python home/linuxbrew/.linuxbrew/Cellar/python#2/2.7.16/bin/python
ln: failed to create symbolic link 'home/linuxbrew/.linuxbrew/Cellar/python#2/2.7.16/bin/python': No such file or directory
➜ 2.7.16 ln -s home/linuxbrew/.linuxbrew/Cellar/python#2/2.7.16/bin/python /home/linuxbrew/.linuxbrew/bin/python
ln: failed to create symbolic link '/home/linuxbrew/.linuxbrew/bin/python': File exists
At the moment linux brew python installation is at 2.7.16_1 folder not 2.7.16. How do I fix this ? I want to create link so whenever it looks for python at 2.7.16/bin/python it should rather look into 2.7.16_1/bin/python.
Is this even possible ?
And how can I solve this, any ideas ? I tried uninstalling and reinstalling docker and python.
When installing a formula via brew it will symlink necessary binaries to a bin directory that's on your PATH. Try re-linking the formula:
brew link --overwrite python
Otherwise, it appears the docker-compose formula depends on python 3.
I found the solution.
I uninstalled docker apt remove docker as it is suggested at their website
sudo apt-get remove docker docker-engine docker.io containerd runc
then I had installed docker and docker-compose using linuxbrew.
But it was still somehow using the /home/username/.local/bin/docker-compose, so I deleted it. I figured that once i ran docker-compose, it gave the same error but also ran successfully. Somehow it was running both of the executables.
So I just rm /home/username/.local/bin/docker-compose and it was fixed.

VS Code can't find python 3 interpreter

I am installing Python 3.7.2 for the first time, and I'm using the VS Code python extension.
When I run python -V I get Python 2.7.10 which is not correct!
When I select the usr/local/bin/python3 interpreter in VS Code I get this error when running a script:
bash: /Users/erik/Work/Python/usr/local/bin/python3: No such file or directory
But when I look in usr/local/bin I can see that Python3 is there. I'm not sure why VS Code pastes the work directory in front of usr/local/bin ?
My first thought was that Python3 should be in the PATH variable so I ran the included Update Shell Profile command, which gives this feedback:
This script will update your shell profile when
the 'bin' directory of python is not early enough
of the PATH of your shell.
All right, you're a python lover already
Now, after rebooting VS Code I get a new option for selecting an interpreter:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
Is that different from the Python in usr/local/bin ? When I select it, I get this error:
The script isort is installed in '/Users/erik/Library/Python/3.7/bin' which is not on PATH.
I also get this sideways related error:
You are using pip version 18.1. You should consider upgrading via the 'pip install --upgrade pip' command.
But, when following these instructions I get yet another error:
bash: pip: command not found
All in all, this process and the official documentation seem less than user-friendly? Apparently I'm required to dig deep through my mac's system files in the terminal before even writing one line of code.
Am I missing an essential step here?
I suggest that you use virtual environment for your project
first
pip install virtualenv
open cmd in your project directory that you open in VS-Code (it's important that vs-code sees this virtualenv folder that we will create)
mkvirtualenv my_env
and it will activate it automatically. if not run
my_env/bin/Scripts/activate or my_env/Scripts/activate
Then go open vs-code then select my_env for python interpreter
Well, if you want to change your default Python version for the whole system, it might break some applications that are depending on Python 2.
You can alias the commands by adding this line to your ~/.bash_profile:
$ alias python='python3'
The python command will now refer to python3.
If you want to execute the original Python (which refers to python2), you can escape the alias (so \python will launch python2 without touching the alias).
Btw.
$ unlink /usr/local/bin/python
$ ln -s /usr/local/bin/python3.7 /usr/local/bin/python
could also be a workaround for you.

Python not Running on GitBash

I just entered a class as an introduction to Python, and so I downloaded GitBash and Andaconda on my Windows laptop. I navigated to my python file on GitBash and tried to execute my python file, to no avail. I searched this website for answers on what to do and tried as many solutions as I could find, but I had no luck. I am quite a noob at this, so I think I am missing something obvious. Perhaps just one line of code that could save me?
...
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ ls
python_intro.py
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ python python_intro.py
bash: python: command not found
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ PATH=$PATH:/c/Python27/
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ python python_intro.py
bash: python: command not found
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ export PATH="$PATH:/c/Python27"
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ python python_intro.py
bash: python: command not found
TECH-TESTER+usd#Tech-tester MINGW64 ~/Desktop/Python-Essentials/PythonIntro
$ python
bash: python: command not found
Sorry if this is such a rookie question, it just seems that everything I find on the internet is above my level to understand, whereas I am at this very basic level.
Meanwhile, I thought Anaconda came with the same py launcher as "official" Python, and offered the same option to install it to somewhere on your PATH.
Try first to check that in a regular CMD.
where python
That will check if python is in the PATH or not.
From there, you can start using python, in a CMD or a git bash session.
Here is the process you can follow to run the Python on your Git Gash.
Launch the program Git Bash in the usual way that you launch Windows programs or VScode. A shortcut for Git Bash was created during installation.
At the command prompt, paste this command export PATH="$PATH:/C/Users/ComputerName/AppData/Local/Programs/Python/Python37-32". That will tell Windows where to find Python. (This assumes that you installed it in export PATH="$PATH:/C/Users/ComputerName/AppData/Local/Programs/Python/Python37-32", as we told you to above.)
Check to make sure that this worked correctly by entering the command python --version. It should say Python 2.7.8 (or 2.7.something), as shown in the figure below.
Assuming that worked correctly, you will want to set up git bash so that it always knows where to find python. To do that, enter the following command:
echo 'export PATH="$PATH:/C/Users/ComputerName/AppData/Local/Programs/Python/Python37-32"' > .bashrc. That will save the command into a file called .bashrc. It will be executed every time git bash launches, so you won’t have to manually tell the shell where to find python again.
Check to make sure that worked by typing exit, relaunching git bash, and then typing python --version again.
Apply above process inside your project folder so that you can use it on VScode.

How to set python path with git bash in windows?

Using Git Bash on Windows 10.
python version: 2.7.12
When run pip, it shows:
$ pip
bash: /c/cygwin/bin/pip: /usr/bin/python2.7: bad interpreter: No such file or directory
How to find the right python path with pip?
Addition
$ which python
/c/cygwin/bin/python
Your pip is somehow using the wrong path for your python that doesn't exist. However, there is a simple workaround, you can type this to specify the python interpreter you want to use:
$ /c/cygwin/bin/python -m pip install yourpackage
This is only a temporary workaround, to fix it, try something from this question.

Categories

Resources