How to fix errors when doing a git commit? - python

I am currently trying to do a simple git commit -m "first commit" but it is not working
whenever i run this command:
git commit -m "first commit"
I get this error:
env: python3.7: Not a directory
My first attempt was to do brew upgrade python
This pointed python3 to python#3.8.
I ran the git command again but I am still have the same issue.
if i have upgraded to python3.8 why is my terminal still giving me the error:
env: python3.7: Not a directory
My second attempt was to check the environment variable by running the env command
but i do not see any environment variable set to python3.7
After reading python location on mac osx
My third attempt was to create a symbol link to python3.7.
so i did
ln -s /usr/local/Cellar/python/3.7.7/bin/python3.7 /usr/local/bin/python3.7
ln -s /usr/local/Cellar/python/3.7.7/bin/python3.7-config /usr/local/bin/python3.7-config
After this i tested by running a git commit command. The result was
Traceback (most recent call last):
File ".git/hooks/pre-commit", line 44, in <module>
os.execvp(CMD[0], CMD)
File "/usr/local/Cellar/python/3.7.7/bin/../Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 574, in execvp
_execvpe(file, args)
File "/usr/local/Cellar/python/3.7.7/bin/../Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 616, in _execvpe
raise last_exc
File "/usr/local/Cellar/python/3.7.7/bin/../Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 607, in _execvpe
exec_func(fullname, *argrest)
NotADirectoryError: [Errno 20] Not a directory
Please can you help me to resolve this problem.
Thank you

Traceback (most recent call last):
File ".git/hooks/pre-commit", line 44, in <module>
You've installed a bad pre-commit hook.

Related

About the error in the installation steps of readthedocs local server

I'm trying to install readthedocs on my local gitlab server and I'm following the guide in the link.
ReadThedocs Guide
Here's the python version and pip version I'm using;
Python3.9
Pip3.9
To run the virtual pip environment, I use the following command.
python3.9 -m venv tutorial-env # I completed the install process with this command.
source tutorial-env/bin/activate # with this command I access the virtual pip environment
my steps in the virtual pip environment;
I run this from the readthedocs installation steps.
(tutorial-env) [redhat#gitlab tutorial-env]$ pip install -r requirements.txt
And no error occurred.
(tutorial-env) [redhat#gitlab tutorial-env]$ python3.9 /home/redhat/readthedocs.org/manage.py migrate
Gave the following error message
[debug ] Using slumber v2. [readthedocs.api.v2.client] api_host=http://127.0.0.1:8000 username=test
Traceback (most recent call last):
File "/home/redhat/readthedocs.org/manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/redhat/tutorial-env/lib64/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/redhat/tutorial-env/lib64/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
django.setup()
File "/home/redhat/tutorial-env/lib64/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/redhat/tutorial-env/lib64/python3.9/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/redhat/readthedocs.org/readthedocs/core/apps.py", line 15, in ready
import readthedocs.core.signals # noqa
File "/home/redhat/readthedocs.org/readthedocs/core/signals.py", line 17, in <module>
from readthedocs.core.unresolver import unresolve
File "/home/redhat/readthedocs.org/readthedocs/core/unresolver.py", line 16, in <module>
#dataclass(slots=True)
TypeError: dataclass() got an unexpected keyword argument 'slots'
However, when I run the python manage.py migrate command in the pip virtual environment, I get the following error message and I can't complete the installation process. What exactly this problem points to?
Thank you for support.
I haven't tried any solutions because I don't understand what is causing the problem.
You are following an outdated and unofficial documentation of Read the Docs (https://read-the-docs.readthedocs.io/en/latest/install.html). The official guide is a lot more updated and uses Docker now, which is easier to setup. Please, read the official guide at https://docs.readthedocs.io/en/latest/development/install.html

incredibly odd error message for python pip

i was using python today and needed to update pip. I ran the standard python -m pip --upgrade install pip command as system admin but now pip can't do anything and gives a quite bizarre error message:
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
status = self.run(options, args)
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 253, in run
options.use_user_site = decide_user_install(
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 604, in decide_user_install
if site_packages_writable(root=root_path, isolated=isolated_mode):
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 548, in site_packages_writable
return all(
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 549, in <genexpr>
test_writable_dir(d) for d in set(get_lib_location_guesses(**kwargs))
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\utils\filesystem.py", line 140, in test_writable_dir
return _test_writable_dir_win(path)
File "C:\Users\adams\AppData\Roaming\Python\Python38\site-packages\pip\_internal\utils\filesystem.py", line 153, in _test_writable_dir_win
fd = os.open(file, os.O_RDWR | os.O_CREAT | os.O_EXCL)
PermissionError: [Errno 13] Permission denied: 'c:\\program files (x86)\\python38-32\\Lib\\site-packages\\accesstest_deleteme_fishfingers_custard_al9l45'
WARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\program files (x86)\python38-32\python.exe -m pip install --upgrade pip' command.
this is the output if I run any pip updating or even just calling pip install on any package. the referenced file mentioned at the end does not seem to exist on my PC. does anyone know what it is?
PS I have tried running command prompt and PowerShell as both admin and normal user and each time get this exact error

pip error calling lsb_release when installing new package

I'm trying to configure 2 Ubuntu servers to use Python and Tensorflow for my project. I finished the 1st server, however, there are some very unusual and annoying errors with the 2nd one. This is the log when I run pip check on the 1st server:
~$: pip check
No broken requirements found.
And the error log on the 2nd one:
~$: pip check
No broken requirements found.
Traceback (most recent call last):
File "/home/mju-hpc-02/.local/bin/pip", line 11, in <module>
sys.exit(main())
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/home/mju-hpc-02/.local/lib/python3.5/site-
packages/pip/_vendor/distro.py", line 931, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero
exit status 1
This error also shows everytime I'm trying to install a new package with pip. Anyone faced similar problems with pip or having a way to diagnose the error?
EDIT 1:
As languitar suggestion, I ran lsb_release -a on both machines and this is the log on the 1st one:
~$: lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
2nd one:
~$: lsb_release -a
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 25, in <module>
import lsb_release
ImportError: No module named 'lsb_release'
You did not mention your Python version(s) available on your system.
Not sure how this happen, but often 'lsb_version' is available to run on python v2 and others on v3.
Most likely you have a multiple python version on your host.
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero
exit status 1
Is, indeed, failing because the 'lsb_release' library called by '/usr/bin/lsb_release' is not available for your particular Python version.
Your first attempt to fix this is simple:
sudo apt install lsb-release
Note is '-' and not '_'
Try again, if keep failing try the following: Look for your Python version library on /usr/lib, and confirm that 'lsb_release.py' is not there. Then, link the shared version to your library:
ln -sfv /usr/share/pyshared/lsb_release.py /usr/lib/python3.7/site-packages/lsb_release.py
Last resource, search /usr for any lsb_release.py and link it to your Python library.
find /usr -name lsb_release.py
You can just use default lsb_release or perhaps a bit modified version:
1 #!/bin/bash
171 [ -z "$LSB_VERSION" ] && LSB_VERSION="1.4"
172 #$MSG_NA
It seems your lsb_release binary is broken. Try to reinstall lsb-release (ubuntu or debian package).

Conda Update fails with PermissionError

I'm on Mac OS 10.9 and running Python 3.5.2
I tried updating conda
conda update conda
but it gave me this error
Traceback (most recent call last):
File "/Users/cd/anaconda3/bin/conda", line 6, in <module>
sys.exit(main())
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main.py", line 139, in main
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main.py", line 146, in args_func
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main_update.py", line 64, in execute
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/install.py", line 424, in install
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/plan.py", line 539, in execute_actions
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 149, in execute_instructions
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 92, in LINK_CMD
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 88, in link
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/install.py", line 634, in link
File "/Users/cd/anaconda3/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/cd/anaconda3/etc/fish/conf.d’
I searched around and thought the problem was that I needed to chown the folder with my user (which is 'cd' in my case):
sudo chown -R cd anaconda3
Then I tried conda update conda, but now it gives a different error:
zsh: /Users/cd/anaconda3/bin/conda: bad interpreter: /opt/anaconda1anaconda2anaconda3/bin/python3: no such file or directory
I tried putting chownback to root:
sudo chown -R root anaconda3
but when I tried conda update conda it gave me the same "bad interpreter" error.
where conda gives /Users/cd/anaconda3/bin/conda
I don't know if the problem was the chowncommand or not, but please let me know if you need any more details!
Your shebang line in /Users/USER/anaconda/bin/conda is broken:
#!/opt/anaconda1anaconda2anaconda3/bin/python
just switch it back to point to the link of your install of Anaconda:
#!/Users/USER/anaconda/bin/python

Conceptnet5 python setup mac OS

I am trying to install conceptnet locally on a mac.
I took The high-bandwidth, low-computation way https://github.com/commonsense/conceptnet5/wiki/Running-your-own-copy and did the following:
git clone https://github.com/commonsense/conceptnet5
pyvenv-3.4 conceptnet-env
source conceptnet-env/bin/activate
cd conceptnet5
python setup.py develop
make download_db
Then at the last step i am getting the following error :
command
ln -s `readlink -f data` ~/.conceptnet5
output
readlink: illegal option -- f
usage: readlink [-n] [file ...]
So i did ignored this step, because i had seen a google discussion which proposed another method (as the link command was not working for me)
So from this discussion https://github.com/commonsense/conceptnet5/issues/33 I tried the following :
CONCEPTNET_DATA=~/conceptnet5/data/
export CONCEPTNET_DATA
But this didnt work, cause when doing the following :
from conceptnet5.query import lookup
lookup('/c/en/examples')
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/query.py", line 75, in lookup
self.load_index()
File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/query.py", line 58, in load_index
self._db_filename, self._edge_dir, self.nshards
File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/formats/sql.py", line 211, in __init__
self._connect()
File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/formats/sql.py", line 216, in _connect
self.dbs[i] = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file
What should be the OS equivalent of the ln command?
Or what else can i do for conceptnet to locate the database file ?

Categories

Resources