Upgrade to 13.04 has totally messed my system up .
I am having this issue when running
./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/rats/rats/local/lib/python2.7/site-packages/django/core/management
/__init__.py", line 4, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/usr/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/rats/rats/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/rats/rats/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/rats/rats/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/rats/rats/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
this is happening for both the real environment as well as for virtual environment .
i tried removing python with
sudo apt-get remove python
and sadly it has removed everything .
now google chrome does not show any fonts .
i am looking for getting things back to work .
help is needed for proper configuring it again.
If you are using virtualenvwrapper then you can recreate the virtualenv on top of the existing one (with no environment currently active):
mkvirtualenv <existing name>
which should pull in the latest (upgraded) python version from the system and fix any mismatch errors.
You don't need to recreate the environment.
You can upgrade the virtualenv running this command:
virtualenv /PATH/TO/YOUR_OLD_ENV
YOUR_OLD_ENV folder will be properly upgraded to the version 2.7.4.
I have just solved that problem on my machine.
The problem was that Ubuntu 13.04 use python 2.7.4. That makes conflict with the Python version of the virtualenv.
What I do was to re-create the virtualenv with the new version of python. I think it's the simplest way, but you can try to upgrade the python version without re-creating all of the virtualenv.
Related
I'm using Mac M1 and I'm having trouble opening Odoo. I try to run the command python3 odoo-bin --i base d db15 --limit-memory-hard 0 but it fails
File "/Users/simjiahong/odoo/odoo-bin", line 5, in <module>
import odoo
File "/Users/simjiahong/odoo/odoo/__init__.py", line 113, in <module>
from . import modules
File "/Users/simjiahong/odoo/odoo/modules/__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry
File "/Users/simjiahong/odoo/odoo/modules/graph.py", line 10, in <module>
import odoo.tools as tools
File "/Users/simjiahong/odoo/odoo/tools/__init__.py", line 21, in <module>
from .convert import *
File "/Users/simjiahong/odoo/odoo/tools/convert.py", line 33, in <module>
from odoo import SUPERUSER_ID, api
File "/Users/simjiahong/odoo/odoo/api.py", line 1024, in <module>
from odoo.modules.registry import Registry
File "/Users/simjiahong/odoo/odoo/modules/registry.py", line 21, in <module>
from odoo.sql_db import TestCursor
File "/Users/simjiahong/odoo/odoo/sql_db.py", line 21, in <module>
import psycopg2.extras
ModuleNotFoundError: No module named 'psycopg2.extras'```
Have you tried installing the psycopg2 python module?
I haven't used M1 Mac (or any Mac recently), but in general (Linux/Windows/Android) you can install python modules using the pip or pip3 command (whichever exists on your system). Like this:
pip3 install psycopg2
or:
pip install psycopg2
You might need root access to do this, or use the --user option, like:
pip3 install --user psycopg2
Also, you can use a similar command if you use a virtual environment inside that (venv, anaconda, etc.).
I try to install dash on a mac OS, and I have the following error when running 'import dash' on a python script:
Traceback (most recent call last):
File "app.py", line 16, in <module>
import dash
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/__init__.py", line 5, in <module>
from .dash import Dash, no_update # noqa: F401,E402
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/dash.py", line 17, in <module>
from flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/__init__.py", line 1, in <module>
from .flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/flask_compress.py", line 14, in <module>
import brotli
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/brotli.py", line 8, in <module>
import _brotli
ModuleNotFoundError: No module named '_brotli'
I can't figure it out what is the problem. I use python 3.7. I saw on the internet a similar issue on windows, but not on mac. I would be really grateful if you could help me.
You seem to have a broken installation of the brotli module (missing its native code component _brotli).
Try uninstalling it with pip uninstall brotli, then reinstall it; pip install brotli.
Going forward, I would heavily recommend you learn and use virtualenvs instead of installing everything into your Python's site-packages.
After uninstalling and installing again brotli it worked! Moreover, working in virtual environments is really more appropriate. Thank you a lot, AKX.
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.
I followed djangogirls tutorial to get started with django and had everything working. Once I finished the basic tutorial, everything in working order, I decided to go through the steps again to make something new and become more familiar with using git, django, venv, etc.
fyi - I am on windows 10 and have python 2.7 and python 3.5 installed. I am using python 3.5.2 with django 1.10.4.
steps:
>mkdir v2
>cd v2
>"d:/python 3.5.2/python" -m venv myenv
>cd myenv/scripts/activate
(myenv) python -m pip install -U pip
for some reason this is the only way I was able to upgrade pip this time around
(myenv) d:/v2/myenv/scripts> pip install django~=1.10.0
(myenv) d:/v2/myenv/scripts> django-admin.py startproject mysite
This is where the magic doesn't happen:
d:\v2>django-admin.py startproject mysite2
Traceback (most recent call last):
File "D:\v3\myenv\Scripts\django-admin.py", line 2, in <module>
from django.core import management
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 10, in <module>
from django.apps import apps
File "C:\Python27\lib\site-packages\django\apps\__init__.py", line 1, in <module>
from .config import AppConfig
File "C:\Python27\lib\site-packages\django\apps\config.py", line 4, in <module>
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
File "C:\Python27\lib\site-packages\django\core\exceptions.py", line 5, in <module>
from django.utils.encoding import force_text
File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 11, in <module>
from django.utils.six.moves.urllib.parse import quote, unquote
File "C:\Python27\lib\site-packages\django\utils\six.py", line 92, in __get__
result = self._resolve()
File "C:\Python27\lib\site-packages\django\utils\six.py", line 160, in _resolve
module = _import_module(self.mod)
File "C:\Python27\lib\site-packages\django\utils\six.py", line 82, in _import_module
__import__(name)
File "C:\Python27\lib\urllib.py", line 26, in <module>
import socket
File "C:\Python27\lib\socket.py", line 47, in <module>
import _socket
ImportError: Module use of python35.dll conflicts with this version of Python.
As far as I am aware, I followed the same steps. I am not sure why the djano installed in my venv would be referencing python 2.7, since I thought if created my venv from the python 3.5.2 dir it would reference that version, along with anything I used pip for within that dir?
Can someone help me find what I am missing here? ty.
By default virtualenv uses python2. If you want to use python3, you have to specify it explicitly.
Run following command to setup virtualenv with python3:
virtualenv -p python3 envname
While in "Python 3.5.2/scripts" I ran:
virtualenv d:/<dirname>
Everything after(django-admin.py startproject projectname) worked correctly. Still not sure what went wrong here but maybe this helps someone else...
I install a python2.7.6 locally, and there is another 2.7.6 installed on cluster publicly.
Then I use my local python to install a pip but when I 'pip list', it returns:
$ pip list Traceback (most recent call last): File
"/home/zengh/.local/bin/pip", line 7, in
from pip import main File "/home/zengh/.local/lib/python2.7/site-packages/pip/init.py", line
13, in
from pip.utils import get_installed_distributions, get_prog File "/home/zengh/.local/lib/python2.7/site-packages/pip/utils/init.py",
line 5, in
import locale File "/home/software/rhel6/python/2.7.6/lib/python2.7/locale.py", line 18,
in
import operator ImportError: /home/software/rhel6/python/2.7.6/lib/python2.7/lib-dynload/operator.so:
undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString
Obviously it calls the locale.py on the cluster while my PYTHONPATH only contains my local python's path. How can I make it call the
/.local/python2.7.6/lib/python2.7/locale.py?
Thanks
Depends on whether you want to set it from within a script or from os.
From script:
import sys
sys.path.append('additional dir')
From os:
export PYTHONPATH=somewhere