djangocms: AttributeError: 'FileNotFoundError' object has no attribute 'cmd' - python

I am trying to install Django CMS on windows. I am using following steps.
C:\Python34\Scripts\pip install djangocms-installer
E:\Projects\example>C:\Python34\Scripts\djangocms -p mysite mysite
But throws following error:
Creating the project
Please wait while I install dependencies
*****************************************************************
Check documentation at https://djangocms-installer.readthedocs.io
*****************************************************************
Traceback (most recent call last):
File "c:\python34\lib\site-packages\djangocms_installer\install\__init__.py",
line 95, in requirements
output = subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)
File "c:\python34\lib\subprocess.py", line 607, in check_output
with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
File "c:\python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "c:\python34\lib\subprocess.py", line 1114, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python34\Scripts\djangocms.exe\__main__.py", line 9, in <module>
File "c:\python34\lib\site-packages\djangocms_installer\main.py", line 33, in
execute
verbose=config_data.verbose
File "c:\python34\lib\site-packages\djangocms_installer\install\__init__.py",
line 98, in requirements
logger.error('cmd : %s :%s' % (e.cmd, e.output))
AttributeError: 'FileNotFoundError' object has no attribute 'cmd'
I have searched on it but can't get any solution.

The root cause is this line:
output = subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)
so put the PATH on the pip executable location and it should work:
set PATH=%PATH%;C:\Python34\Scripts
At first glance, sounds that the package is not very adapted to Windows environment... The double exception is not very nice, and calling pip without any path can be a problem.

Related

Issue while integrating PyCharm with Databricks cluster

I am trying to integrate PyCharm with my team's Databricks cluster using databricks-connect. I created a venv and did a pip install databricks-connect. Then I configured it with the necessary info of databricks cluster. When I run databricks-test, I see the following error. I followed this databricks documentation. I am using Python 3.8 and databricks-connect 9.1.(since the cluster runs this version). I tried changing version of databricks-connect to 10.4. but the same issue shows up again, been experimenting with different versions(tried creating a virtual environment through Anaconda prompt, but that too ran into the same issue). Any help is appreciated.
(venv) C:\Users\xxxxxxxx>databricks-connect test
* PySpark is installed at C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark
* Checking SPARK_HOME
* Checking java version
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
* Skipping scala command test on Windows
* Testing python command
Traceback (most recent call last):
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\Scripts\databricks-connect.exe\__main__.py", line 7, in <module>
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\databricks_connect.py", line 283, in main
test()
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\databricks_connect.py", line 248, in test
spark = SparkSession.builder.getOrCreate()
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\sql\session.py", line 229, in getOrCreate
sc = SparkContext.getOrCreate(sparkConf)
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\context.py", line 392, in getOrCreate
SparkContext(conf=conf or SparkConf())
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\context.py", line 145, in __init__
SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\context.py", line 339, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "C:\Users\xxxxxxxx\Documents\pythonProject\venv\lib\site-packages\pyspark\java_gateway.py", line 101, in launch_gateway
proc = Popen(command, **popen_kwargs)
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1334, in _execute_child
_winapi.CloseHandle(ht)
OSError: [WinError 6] The handle is invalid
Exception ignored in: <function Popen.__del__ at 0x000002CA0B15C0D0>
Traceback (most recent call last):
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 949, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1348, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
Exception ignored in: <function Handle.Close at 0x000002CA0B15B3A0>
Traceback (most recent call last):
File "C:\Users\xxxxxxxx\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 194, in Close
CloseHandle(self)
OSError: [WinError 6] The handle is invalid

Spyder Permission Error while starting the Kernel, Administrator rights do not change anything

when I start Spyder I get an error that says permission denied. This is the output from that in Spyder:
An error ocurred while starting the kernel
The error is:
Traceback (most recent call last):
File "C:\Users\John\anaconda3\lib\site‑packages\spyder\plugins\ipythonconsole\plugin.py", line 1223, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle)
File "C:\Users\John\anaconda3\lib\site‑packages\jupyter_client\manager.py", line 313, in start_kernel
self.kernel = self._launch_kernel(kernel_cmd, **kw)
File "C:\Users\John\anaconda3\lib\site‑packages\jupyter_client\manager.py", line 220, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "C:\Users\John\anaconda3\lib\site‑packages\jupyter_client\launcher.py", line 131, in launch_kernel
proc = Popen(cmd, **kwargs)
File "C:\Users\John\anaconda3\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\John\anaconda3\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
It eventual pops up with a prompt that says
link to image
The advice I've found is to run Spyder in with administrator rights, but this does not fix my issue. I've found some other advice to do the following
As per #CarlosCordoba: "To fix this the OP needs to run conda update anaconda and then conda update jupyter_client in the Anaconda Prompt"
When I run conda update anaconda in the Anaconda cmd prompt with administrator rights this is what happens
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: - menuinst Exception
Traceback (most recent call last):
File "C:\Users\John\anaconda3\lib\site-packages\conda\gateways\disk\create.py", line 246, in make_menu
menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 58, in install
_install(path, remove, prefix, mode='system')
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 33, in _install
data = json.load(open(path))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\John\\anaconda3\\Menu\\notebook.json'menuinst Exception
Traceback (most recent call last):
File "C:\Users\John\anaconda3\lib\site-packages\conda\gateways\disk\create.py", line 246, in make_menu
menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 58, in install
_install(path, remove, prefix, mode='system')
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 33, in _install
data = json.load(open(path))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\John\\anaconda3\\Menu\\notebook.jsodone
Rolling back transaction: - menuinst Exception
Traceback (most recent call last):
File "C:\Users\John\anaconda3\lib\site-packages\conda\gateways\disk\create.py", line 246, in make_menu
menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 58, in install
_install(path, remove, prefix, mode='system')
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 33, in _install
data = json.load(open(path))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\John\\anaconda3\\Menu\\notebook.json'menuinst Exception
Traceback (most recent call last):
File "C:\Users\John\anaconda3\lib\site-packages\conda\gateways\disk\create.py", line 246, in make_menu
menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 58, in install
_install(path, remove, prefix, mode='system')
File "C:\Users\John\anaconda3\lib\site-packages\menuinst\__init__.py", line 33, in _install
data = json.load(open(path))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\John\\anaconda3\\Menu\\notebook.jsodone
[WinError 5] Access is denied
()
Any help? I've only got a little knowledge in Python, and using this for mathematical optimization in a class.
EDIT: A little extra information. When I try to launch Spyder from the Anaconda Navigator it just spins forever, never launching.
I fixed it! I did a soft boot, and then in the Anaconda terminal ran spyder --reset. Then, ran Spyder with Administrative privileges, and it was able to connect!

pip3 error : AttributeError: module 'platform' has no attribute 'linux_distribution'? (ubuntu 20.04 with python 3.8)

I think i have messed up some python files when installing some packages in a requirement.txt file
now i get these errors when trying to install or uninstall anything:
for example when trying to uninstall matplotlib without sudo using pip3 uninstall matplotlib (even tho i never had to use sudo to uninstall anything before) :
Found existing installation: matplotlib 3.3.1
Uninstalling matplotlib-3.3.1:
Would remove:
/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/shutil.py", line 788, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg' -> '/tmp/pip-uninstall-nw393b36'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py", line 89, in run
uninstall_pathset = req.uninstall(
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 686, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
moved.stash(path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
renames(path, new_path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 352, in renames
shutil.move(old, new)
File "/usr/lib/python3.8/shutil.py", line 800, in move
rmtree(src)
File "/usr/lib/python3.8/shutil.py", line 715, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.8/shutil.py", line 672, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib/python3.8/shutil.py", line 670, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'pylab.py'
When trying with sudo :
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/local/lib/python3.8/dist-packages/pip/commands/uninstall.py", line 46, in run
with self._build_session(options) as session:
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 33, in <module>
sys.exit(load_entry_point('pip==20.3.dev0', 'console_scripts', 'pip3')())
File "/usr/local/lib/python3.8/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 242, in main
with self._build_session(
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
How can i fix this? i am using ubuntu 20.04 and i heard uninstalling python3.8 is a big no no since many system files use it, so what should i do?
tried many suggestion on similar questions like this and it didn't work:
How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?
Python 3.8 removed some stuff. I solved my problems with pip (specifically pip install) by installing pip with curl
What worked for me was:
cd ~/Downloads
Downloading get-pip.py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then running it with python 3.8:
python3.8 get-pip.py
Solved it for me.

FileNotFoundError with blend2bam

So I tried converting a .blend file to .bam with blend2bam as suggested by the official Panda3D page but I am getting a FileNotFoundError.
I am using Windows with Python3.7 (from the Panda3D install).
I tried a lot of possibilities of how one could address the src and dst but it still did not work.
C:\Panda3D-1.10.6-x64\mystuff\pandatest>blend2bam C:\Panda3D-1.10.6-x64\mystuff\pandatest\car_model.blend C:\Panda3D-1.10.6-x64\mystuff\pandatest\
Traceback (most recent call last):
File "c:\panda3d-1.10.6-x64\python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\panda3d-1.10.6-x64\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Panda3D-1.10.6-x64\python\Scripts\blend2bam.exe\__main__.py", line 9, in <module>
File "c:\panda3d-1.10.6-x64\python\lib\site-packages\blend2bam\cli.py", line 195, in main
use_gltf28 = blenderutils.is_blender_28(args.blender_dir)
File "c:\panda3d-1.10.6-x64\python\lib\site-packages\blend2bam\blenderutils.py", line 22, in is_blender_28
output = subprocess.check_output([binpath, '--version'])
File "c:\panda3d-1.10.6-x64\python\lib\subprocess.py", line 411, in check_output
**kwargs).stdout
File "c:\panda3d-1.10.6-x64\python\lib\subprocess.py", line 488, in run
with Popen(*popenargs, **kwargs) as process:
File "c:\panda3d-1.10.6-x64\python\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "c:\panda3d-1.10.6-x64\python\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
Ran into same error. It calls blender so needs to know where to find it:
blend2bam --blender-dir "C:\Program Files\Blender Foundation\Blender 2.82" test.blend test_bam_dir
My workaround is using Blender2.7 and Yabee.
I've had the same problem today and I think I've solve it eventually. You need to use blender installation directory as argument. Here is mine:
File names:
(source) >> cube.blend
(dest)>> cube.bam
Example:
blend2bam cube.blend cube.bam --blender-dir D:\Programs\Blender
The trick is path must be simple. No spaces etc.
I hope it helps
Niyazi

How do I use the 'keyboard' python module in a docker container without an error?

I am trying to use the python module keyboard in a docker container for testing automation that emulates keyboard presses. However, this module continually returns an error in the docker container whereas it works fine in an ubuntu VM.
I have installed different commonly used docker containers and different versions of python. I get the same error. Sadly, google hasn't been as helpful as it usually is here.
Here's an easily reproducible version of what I've done:
docker run -t -d -u root --name docker_container python:3.7
echo $(docker exec -u root docker_container bash -c 'python3 -m keyboard' )
This returns the below error message:
/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
device = aggregate_devices('kbd')
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/site-packages/keyboard/__main__.py", line 10, in <module>
keyboard.hook(print_event_json)
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 459, in hook
append(callback)
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 67, in add_handler
self.start_if_necessary()
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 194, in init
_os_keyboard.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 114, in init
build_tables()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 73, in build_tables
dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
File "/usr/local/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dumpkeys': 'dumpkeys'
From what I understand, it can't access a uinput device / keyboard to be able to dump the keys. Is there a way to virtually simulate a keyboard in the container to allow this to work?
try to install the following:
apt-get install -y kmod kbd
since you need this to get dumpkeys

Categories

Resources