I'm on Windows 10.
I tried to install channels to use websockets with Django but it doesn't work. I got the following error :
Failed building wheel for Twisted
I have still not succeeded to install channels.
But now I have a new problem, I can no anymore access Python shell from my virtual environment that I use for Django.
(myproject) D:\Django\mysite>py manage.py shell
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\kevin\Envs\myproject\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'channels'
I have no idea to solve my problem ... Someone could bring me help ?
Try install channels by using pip install channels
then run shell again
Seems like you broke something when you tried to install channels. From the spares information I guess that easiest course of action is to simply use a new virtual environment. After all that is the point of a virtual environment, if it breaks you can just rebuild it.
Manually fixing the virtual environment usually (this is my personal experience) takes more time then just setting up a new one.
For your installation trouble we need more info and you should open a new question.
So just deactivate your current environment (this might help), delete it and set up a new one.
Keep in mind that this will only bring the shell back and give you a "fresh start". Your installation problem will usually not disappear!
Related
This is such a basic question, I'm sorry. I installed django-parsley with poetry (poetry add django-parsley). It's clearly installed in my pyproject.toml file.
In my django project files, in forms.py, I have a line of code that imports a module from parsley: from parsley.decorators import parsleyfy
However, when I try to run python manage.py runserver, I get the following error:
from parsley.decorators import parsleyfy
ModuleNotFoundError: No module named 'parsley'
I also tried adding 'parsley' to my INSTALLED_APPS in settings.py. That gives me this error (which is maybe due to not adding it globally with pip install?):
...some more errors...
File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'parsley'
What do I need to do to be able to import it in a python file in my project?
I figured it out. It's actually a VSCode issue - normally, VSCode automatically identifies the right virtual environment for the project (in this case, Poetry's default auto-created project-specific venv).
However, in this project, it didn't switch over. To fix, I ran the Python: Select Interpreter command and switched the venv over to the right project. It then recognized the site-packages folder and was able to import normally.
I have used pyinstaller many times before but I have never faced such issues
I am facing issues while converting .py to .exe using pyinstaller
What I have tried
I have installed pythonnet and opened the directory where pythonnet is stored but i could not find any dll file
I am using the following command
PyInstaller app.py --noconsole --icon=./images/Source.ico
entire Traceback
Traceback (most recent call last):
File "c:\Users\ADMIN.DESKTOP-USLQ9P3\Desktop\jarvis\setup.py", line 3, in <module>
PyInstaller.__main__.run([
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\building\build_main.py", line 725, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\building\build_main.py", line 672, in build
exec(code, spec_namespace)
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\Desktop\jarvis\app.spec", line 6, in <module>
a = Analysis(['app.py'],
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
self.__postinit__()
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\building\build_main.py", line 420, in assemble
self.graph.process_post_graph_hooks()
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\depend\analysis.py", line 367, in process_post_graph_hooks
module_hook.post_graph()
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\depend\imphook.py", line 447, in post_graph
self._load_hook_module()
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\depend\imphook.py", line 408, in _load_hook_module
self._hook_module = importlib_load_source(
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\PyInstaller\compat.py", line 598, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 962, in load_module
File "<frozen importlib._bootstrap_external>", line 787, in load_module
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ADMIN.DESKTOP-USLQ9P3\AppData\Roaming\Python\Python38\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-clr.py", line 40, in <module>
raise Exception(pyruntime + ' not found')
Exception: Python.Runtime not found
I have also install pythonnet but it is still not working neither can I find the dll
This is not a direct answer to your question, but I have had a lot of issues with pyinstaller myself in the past year. At this point I have the process perfected that I almost never have issues anymore. The key for me has been:
Do not use virtual environments (venv). I use a separate older computer specifically for pyinstaller. The computer only has basic python, pycharm and the libraries I need for my build installed to site packages. I install everything globally. I remove libraries I do not need.
If a library causes problems like you describe, try installing an older versio of said library.
To follow up:
Using pycharm does not work or pycharm in general does not work?
What I would recommend you do is what I do on a fresh computer:
Make sure you know which libraries your project requires. You could generate a requirements file: Automatically create requirements.txt
Uninstall python / anaconda from your computer completely incl all libs.
Reinstall python (not anaconda as it has way to many libraries) and click yes if installer asks you to add to path. Install pycharm community edition if you do not have it.
Install pyinstaller and other libs you need, but install them globally! I recommend using pycharm. Settings>yourproject>python interpreter>little plus icon>libraries you need. IMPORTANT: CHOOSE TO INSTALL TO SITE PACKAGE DIRECTORY:
Go to terminal in pycharm and type: pyinstaller --onefile my_python_file.py
You should now get an .exe file. in a dist folder in the directory of your file.
NOTE: the above should not be necessary and pyinstaller can work with virtual environments, but I have found it to be the most reliable way to use pyinstaller.
Try installing py2exe. This program also bundles python programs into .exe files, and I have used it for one of my games. To install this program, simply type into the command line:
python -m pip install py2exe
For more resources on py2exe, check out these links:
http://www.py2exe.org/
https://github.com/py2exe/py2exe
You should reinstall python and add it to your path, that might help you. There are lot of videos online you can refer to.
I have recently performed various software updates as suggested by the "Software Center" on my Ubuntu machine (Ubuntu 18.04.5 LTS).
Now, when I try to import numba (numba==0.51.2) via
python3 -c 'import numba'
I get the following error
double free or corruption (top) Aborted (core dumped)
The same happens when I create a new conda environment with a fresh numba install.
I have looked at the core dump via
gdb -c core
with
thread apply all bt full
but I only get memory address information. I use python 3.6.9 on my machine, but I have also tried 3.8 in a new conda environment, where I get the same error.
I suspect that the software update is the reason for the error described above. But I might be mistaken and something else goes on here.
Is there any other way to get more info on where python crashes? I really don't want to go through the updated libraries one by one and roll them back to find the error.
At least I have now found the library that causes this error.
What I did were the following steps:
put import numba into a file, e.g. importNumba.py
locate python3.X-gdb.py via locate --regex python3.*-gdb.py. In my case it is in /usr/share/gdb/auto-load/usr/bin/python3.6-gdb.py
run python in debug mode via gdb python3 - the gdb console opens
execute source /usr/share/gdb/auto-load/usr/bin/python3.6-gdb.py in the gdb console - this will load the python extensions into gdb
execute run importNumba.py in the gdb console - this will produce above error
execute py-bt in the gdb console
This gives
Traceback (most recent call first):
File "/usr/local/lib/python3.6/dist-packages/llvmlite/binding/ffi.py", line 113, in __call__
return self._cfn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/llvmlite/binding/dylib.py", line 29, in load_library_permanently
_encode_string(filename), outerr):
File "/usr/local/lib/python3.6/dist-packages/numba/__init__.py", line 151, in _try_enable_svml
llvmlite.binding.load_library_permanently("libsvml.so")
File "/usr/local/lib/python3.6/dist-packages/numba/__init__.py", line 201, in <module>
config.USING_SVML = _try_enable_svml()
<built-in method exec of module object at remote 0x7ffff7fb7638>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "importNumba.py", line 1, in <module>
import numba
So it seems something is wrong with libsvml.so.
I found out that numba allows to disable SVML via
setting the environment flag NUMBA_DISABLE_INTEL_SVML to something other than 0, see https://numba.pydata.org/numba-doc/dev/reference/envvars.html
Changing importNumba.py to
import os
# note that this must be executed before 'import numba'
os.environ['NUMBA_DISABLE_INTEL_SVML'] = '1'
import numba
and running it via python3 importNumba.py now works without error.
These were a few useful resources that I used:
https://fedoraproject.org/wiki/Features/EasierPythonDebugging#New_gdb_commands
https://wiki.python.org/moin/DebuggingWithGdb
I'm new to this. I have begun learning OpenCV with Python and following the course directions I've successfully created an Anaconda environment from which I can easily import CV2 and carry out my course. So far, I have experienced no problems in working with this environment.
Now, I would like to begin using Spyder which launches well from the default/base environment but does not launch from the "opencv-course" environment which I created. By contrast, Jupyter Labs and Notebooks launch well on either environment.
I've attempted to uninstall/reinstall Spyder using Administrator privileges when launching Anaconda, but to no avail.
Could anyone forward a suggestion?
Many thanks!
MD
The following error message is displayed:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\opencv-course\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\app\start.py", line 205, in main
mainwindow.main()
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\app\mainwindow.py", line 3734, in main
mainwindow = run_spyder(app, options, args)
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\app\mainwindow.py", line 3590, in run_spyder
main.setup()
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\app\mainwindow.py", line 977, in setup
'spyder.plugins.{}'.format(plugin_name))
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\plugins\pylint\__init__.py", line 14, in
from .plugin import Pylint as PLUGIN_CLASS
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\plugins\pylint\plugin.py", line 29, in
from spyder.plugins.pylint.confpage import PylintConfigPage
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\plugins\pylint\confpage.py", line 16, in
from spyder.plugins.pylint.widgets.pylintgui import PylintWidget
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\plugins\pylint\widgets\pylintgui.py", line 37, in
from spyder.plugins.pylint.utils import get_pylintrc_path
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\spyder\plugins\pylint\utils.py", line 16, in
import pylint.config
File "C:\ProgramData\Anaconda3\envs\opencv-course\lib\site-packages\pylint\config.py", line 54, in
import toml
ModuleNotFoundError: No module named 'toml'
After checking out this answer here:
Spyder failed to launch in Anaconda after update (4.1.2)
I've solved the problem by downgrading the version of Pylint from 2.5 to 2.4.4. It now works fine.
Many thanks!
MD
After installing Anaconda for Python 3.4 on my Mac I get constant messages saying:
Error in sitecustomize; set PYTHONVERBOSE for traceback:
KeyError: 'PYTHONPATH'
As suggested by a user on another question, I used
PYTHONVERBOSE=1 conda update --all
And received the traceback:
Traceback (most recent call last):
File "/Users/user/anaconda/lib/python3.4/site.py", line 506, in execsitecustomize
import sitecustomize
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/usr/local/lib/python2.7/site-packages/sitecustomize.py", line 15, in <module>
str(sys.version_info[0]) + '.x!\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\n' +
File "/Users/user/anaconda/lib/python3.4/os.py", line 633, in __getitem__
raise KeyError(key) from None
KeyError: 'PYTHONPATH'
# destroy sitecustomize
I have looked around and found that 'PYTHONPATH' does not exist as a key in os.environ.
If your PYTHONPATH environment variable is set, unset it. You can check with echo $PYTHONPATH. If it is set it is probably coming from something in ~/.profile or ~/.bash_profile.
The issue is the file /usr/local/lib/python2.7/site-packages/sitecustomize.py. You may want to check what that file is and where it comes from, but removing it should fix the problem.
Going to necro-answer here with more detail for folks that might hit this page after searching for the error shown…
If your Mac has messages referencing /usr/local/, I'm going to go ahead and assume you've used homebrew to install something. In this case, Python.
When Anaconda's Python distribution is installed, one of the things it'll check is if there are any site customizations applied to your existing Python installation. If you installed any version of Python using Homebrew, you likely have such a site customization.
Running conda info -a | grep dirs will get your Anaconda install info and look for a line with dirs included. Only one should match, if it exists:
user site dirs: ~/.local/lib/python3.5
If it does exist, cd to that directory (whatever it is), and get a directory listing (ls). You'll then (likely) find a file called homebrew.pth.
Remove that file, and the error goes away.
Reason: Anaconda is referencing that homebrew.pth file, which then goes on to include the sitecustomize.py from your earlier homebrew-installed version of Python.