Error running django with gunicorn and circus - python

I want to run django on an ubunu 14.04 machine , using gunicorn and circus. when I start gunicorn manually, it works fine, but when I try to run it with circus , this error occurs:
Traceback (most recent call last):
File "/path_to_my_app/venv/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/path_to_my_app/venv/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 10, in <module>
from gunicorn.app.base import Application
File "/path_to_my_app/venv/lib/python3.5/site-packages/gunicorn/app/base.py", line 9, in <module>
import traceback
ImportError: No module named 'traceback'
I have tried deleting virtual environment and creating it again, I have tested the ini file ...
any ideas?

the solution which itzMEonTV suggested, works fine. I don't know what the problem is though! I am using the same ini file that I have on another server. the only difference between these two systems, is the OS version. PYTHONPATH works fine on ubuntu 16.04 but not on 14.04.
anyway, the link suggested by itzMEonTV solved my problem.

Related

Why python software package does not run under WSL2?

I wanted to use WSL2 Ubuntu to run some scientific programs on my PC (Phenix package). It used to work previously on wsl but after recent update to wsl2 one of the programs written in Python has some problems:
Traceback (most recent call last):
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/build/../modules/phenix/wxGUI2/command_line/main.py", line 23, in <module>
run(sys.argv[1:])
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/build/../modules/phenix/wxGUI2/command_line/main.py", line 16, in run
from wxGUI2 import App
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/modules/phenix/wxGUI2/App.py", line 7, in <module>
from SimpleXMLRPCServer import SimpleXMLRPCServer
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/conda_base/lib/python2.7/SimpleXMLRPCServer.py", line 105, in <module>
import BaseHTTPServer
File "/mnt/f/cryoEM/phenix-1.18rc4-3812/conda_base/lib/python2.7/BaseHTTPServer.py", line 102, in <module>
class HTTPServer(SocketServer.TCPServer):
AttributeError: 'module' object has no attribute 'TCPServer'
I have checked all the packages (BaseHTTPServer, SocketServer) and everything seems to be fine. Using python provided with the package and importing modules separately also works without errors. My previous computer also with WSL2 was running this software package without any issues. I believe that there is something missing on the wsl2 Ubuntu level but cannot guess what it is. Do you have any suggestions what I could try to do? Thanks!

Python error in Vim when run inside a 3.5.3 virtualenv

I have multiple Python versions installed with pyenv on Ubuntu 16.04. I create virtual environments to work with projects using different versions with pipenv. However, for Python 3.5.x only I get errors like this when I try to edit a file with Vim 8 (installed via the PPA) in an activated virtualenv:
"test.py" 49L, 1434C
Error detected while processing function jedi#init_python[4]..<SNR>48_init_python[27]..jedi#setup_python_imports:
line 25:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
The issue seems to affect all python related Vim plugins. With other Python versions (e.g. 3.6.x, 3.7.x) this does not occur. What may be causing this issue?
Update: It seems that when I run Vim inside a 3.5.x virtualenv, the Vim's interpreter's sys.path gets updated somehow. For example, this is the output of :py3 import sys; print(sys.path) inside a 3.6.0 virtualenv:
['/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5
/dist-packages', '/usr/lib/python3/dist-packages', '_vim_path_']
And this is for 3.5.3:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
['/must>not&exist', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python35.zip', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/li
b/python3.5', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/plat-x86_64-linux-gnu', '/home/testuser/.local/share/virtualenvs/venv-3.
5-8feRiT5s/lib/python3.5/lib-dynload', '/home/testuser/.pyenv/versions/3.5.7/lib/python3.5', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/pyt
hon3.5/site-packages']
The issue can be reproduced in a ubuntu:16.04 docker container.
Debian Bug report logs - #852163: python3.5-minimal wont configure demonstrates that this error (for Python 3.5 and Python 3.6) is due to another incompatible installation of Python in /usr/local.
Some further digging with another user in #debian who was experiencing this
problem indicated that it was related to a locally installed
/usr/local/bin/python3.5. The stdlib in /usr/lib/python3.5 is picked up by the
/usr/local/bin/python3.5 but is not compatible with it, resulting in the
stacktrace shown.
Removing /usr/local/bin/python3* and all traces of that installation from
/usr/local/lib (plus other associated tools) solved this problem for the user
I was helping in #debian.
-- Stuart Prescott (link)
The problem is caused by the system installed python, which conflicts with personally installed python.
It could be the case that other python versions are interfering here. Do you have a PYTHONPATH set?
echo $PYTHONPATH
If it is set you could try to unset it. It's usually not needed when using virtual environments.
Try running python with sudo. I think the python which comes with OS needs to run with admin privilege.

Heroku Moduke Not Found Error

[![][1]][1]
the module 'pyicloud' is listed in requirements.txt
I have checked using the 'ls' command- I checked the directory in which the package should be - and the package does exist on the heroku server.
The app gives no such issues on my local machine, even though there is no difference in the code
I also tried the suggestions given here : https://help.heroku.com/BWJ7QYTF/why-am-i-seeing-importerror-no-module-named-site-when-deploying-a-python-app
but it didnt work.
(venv)dhcp-10-4-0-197:mes-amis mananhora$ heroku run python manage.py db upgrade -a mesamis
▸ heroku-cli: update available from 6.16.18-62346b1 to 6.99.0-ec9edad
Running python manage.py db upgrade on ⬢ mesamis... up, run.1121 (Free)
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from project import app, db
File "/app/project/__init__.py", line 40, in <module>
from project.import_data.functions import import_data_blueprint
File "/app/project/import_data/functions.py", line 6, in <module>
from pyicloud import PyiCloudService
ModuleNotFoundError: No module named 'pyicloud'

importerror no module named caches

I'm trying to run simulation by using gem5 on ubuntu 16.04 lts
and I write code './build/X86/gem5.opt ./configs/tutorial/two_level.py'.
The output on terminal was:
Traceback(most recent call last):
File "<string>", line 1, in <module>
File "home/park/gem5/src/python/m5/main.py", line 433, in main
exec filecode in scope
File "./configs/tutorial/two_level.py", line 3, in <module>
from caches import*
ImportError: No module named caches
I tried everything I can, but couldn't know. What is the problem?
The file:
configs/tutorial/two_level.py
has never been part of the main tree according to:
git log -p -- '**/two_level.py'
so you must provide its source.
Supposing you are talking about configs/learning_gem5/part1/two_level.py, the problem is not reproducible on master at da79d6c6cde0fbe5473ce868c9be4771160a003b with the command:
./build/X86/gem5.opt configs/learning_gem5/part1/two_level.py
which appears to run correctly.

Can no Longer open Spyder IDE for Python Programming

I installed Python 3.4 on my Windows 7 laptop several months ago as part of Anaconda (https://www.continuum.io/downloads). My installation included the Spyder IDE, and I have successfully been using Spyder for Python programming.
However, since yesterday, I have been unable to open Spyder. I typically open Spyder via the Start Menu, but now, when I try to click on the Spyder icon in the Start Menu, I get no response. I then tried to go directly to the spyder.exe file in the Scripts folder in the directory where Anaconda is installed. When I clicked on this the first time, the following message flashed quickly and then disappeared:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 114, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
I double-clicked on Spyder.exe a second time, and this time, received the following message:
kfile.py", line 146 in lock
symlinke(str(os.getpid()), self.name)
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\utils\external\lockfile.py", line 87, in symlink
os.rmdir(newlinkname)
OSError: [WinError 145] The directory is not empty: 'C:\\Users\\Aniket\\.spyder2-py3\\spyder.lock.1459432906109.newlink'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 106, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
Both of these messages flashed very quickly and then disappeared - I captured them by quickly pressing Print Screen when they appeared. It's not evident to me what the error messages imply, nor what would have caused this. It's possible that I closed Spyder while some function was running, or that Spyder crashed and caused some persistent error. Does anyone know how I can fix this?
I had a similar problem of Spyder 2 not starting. My installation is part of Anaconda, on Win7 64-bit OS. I tried all the solutions outlined here and here, but they did not work for me. From the command line, I got the following error(s) when trying to reset spyder:
U:\>python -c "from spyderlib.spyder import main; main()" --reset
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 48, in <module> from PySide import __version__ # analysis:ignore
ImportError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 40, in check_qt from spyderlib import qt File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 50, in <module>
raise ImportError("Spyder requires PySide or PyQt to be installed")
ImportError: Spyder requires PySide or PyQt to be installed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 48, in <module> requirements.check_qt()
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 50, in check_qt % (qt_infos['pyqt']+qt_infos['pyside']))
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 25, in show_warning
raise RuntimeError(message)
RuntimeError: Please check Spyder installation requirements:
PyQt4 4.6+ (or PySide 1.2.0+) is required.
What surprised me was that spyder worked fine till yesterday, and I just did a full update yesterday as follows:
conda update --all
So I again updated spyder today with the following:
conda update spyder
And the following package plan was presented to me:
The following packages will be UPDATED:
spyder: 2.3.7-py35_3 None://None/<unknown> --> 2.3.8-py35_1
spyder-app: 2.3.7-py35_0 --> 2.3.8-py35_0
The following packages will be DOWNGRADED due to dependency conflicts:
matplotlib: 1.5.3-np111py35_1 --> 1.5.1-np111py35_0
pyqt: 5.6.0-py35_0 --> 4.11.4-py35_7
qt: 5.6.0-vc14_0 [vc14] --> 4.8.7-vc14_9
[vc14]
qtconsole: 4.2.1-py35_2 --> 4.2.1-py35_0
After the update, spyder works fine now.
In essence, my problem was due to dependency conflicts.
I ran into the same issue. The following worked for me
Please close Spyder IDE, in Anaconda Prompt run
conda update spyder
then
spyder --reset
Restart Spyder
Had the same exact problem as you a few days ago and reinstalling won't work so I went to:
C:\Users\'YourName'\\.spyder2-py3
delete every spyder, lock file/folder in it and relaunch.
I know this is an old thread but having just had the same problem an answer that worked for me from https://github.com/spyder-ide/spyder/issues/3005
My problem appeared to be that the status of spyder was still running so wouldn't open. To fix this you need to look for a directory called .spyder2 in your Users\ directory, then find a file called spyder.lock and remove it.
My solution:
I uninstalled Anaconda spyder
Removed all directories of it from
c: programs/
and c:users/Username/
and c:users/username/AppData/local
and c:users/username/AppData/
I downloaded a newer version of Anaconda Spyder and installed it.
It's all fine now.
You might get additional information if you run
from spyder.app import start
start.main()
as a python script. For example I got following output:
Traceback (most recent call last):
File "C:\python_env\workspace\TechDiff\src\demo.py", line 1, in <module>
from spyder.app import start
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\app\start.py", line 24, in <module>
from spyder.config.base import get_conf_path, running_in_mac_app
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\config\base.py", line 25, in <module>
from spyder.utils import encoding
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\utils\encoding.py", line 23, in <module>
from spyder.py3compat import (is_string, to_text_string, is_binary_string,
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\py3compat.py", line 77, in <module>
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (C:\python_env\App\WinPython\python-3.10.1.amd64\lib\collections\__init__.py)
=> Maybe for Python 3.10 the import of collections needs to be fixed.
=> Try to use 3.9
I've got exactly the same error messages before, and I fixed it by installing spyder again under anaconda:
conda install spyder
Well it says it is missing PyQt4.dll, which you can check by: searching pyqt4 in your anaconda3 directory.
There are several possibilities:
it is still in: ~\Anaconda3_x86\Library\plugins\designer
That would mean python can't find since it ain't searching in this directory, I highly doubt that possiblity, since that would mean you'd have tweaked some code.
it ain't anywhere
Maybe you or more likely one of your programs did deleted it per accident?
it isnt in: ~\Anaconda3_x86\Library\plugins\designer
I also doubt this possibilty since it would mean the file has been moved...
However you can fix that by reinstalling spyder as mentioned by xuwei.

Categories

Resources