module 'importlib._bootstrap' has no attribute '_w_long' - python

I am trying to install django-adim-tools using pip, but this is what happens:
C:\Users\hugo.villalobos>pip install django-admin-tools
Could not import runpy module
Traceback (most recent call last):
File "C:\Python34\Lib\runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
File "C:\Python34\Lib\importlib\__init__.py", line 34, in <module>
_w_long = _bootstrap._w_long
AttributeError: module 'importlib._bootstrap' has no attribute '_w_long'
I have no idea how to proceed to solve it.

In my case, I have multiple Python (3.7, 3.6, 3.4) installed in my PC. The environment var $PATH and $PYTHONPATH is pointing to different version's. After resetting these 2 environment vars correctly everything runs correctly then.

had similar issue running the command:
pipenv install --python 3.8
solved by removing python3.8 from environment variable $PATH, and keeping only 3.7 as default python:
C:\Users\MB\AppData\Local\Programs\Python\Python37\Scripts\
C:\Users\MB\AppData\Local\Programs\Python\Python37\

Related

New Anaconda3 installation, ModuleNotFoundError: No module named 'conda'

This is a FRESH installation of Anaconda, so the issues with updating python don't apply here. Uninstalling and reinstalling causes the same errors.
Upon starting up the Anaconda prompt I get this error:
Traceback (most recent call last):
File "D:\AnacondaInstallation\Scripts\conda-script.py", line 11, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
C:\Users\xianx>where conda
INFO: Could not find files for the given pattern(s).
I manually added these three lines to my Path variable, but I'm still getting that error upon opening up the Anaconda prompt.
D:\AnacondaInstallation\Scripts,
D:\AnacondaInstallation,
D:\AnacondaInstallation\Library\bin
I also see it when I try to install any sort of package. The system seems to recognize the conda command enough to run conda-script.py.
D:\AnacondaInstallation\Scripts>conda install pytorch
Traceback (most recent call last):
File "D:\AnacondaInstallation\Scripts\conda-script.py", line 11, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
D:\AnacondaInstallation\Scripts>where conda
D:\AnacondaInstallation\Scripts\conda.exe
D:\AnacondaInstallation\Library\bin\conda.bat
My problem was that I had multiple Python installations all over the place. Once I cleaned those out of my PATH environment variable and put in the Anaconda ones, the issue resolved itself.

trouble installing pip and or queue for python

I have apache ampps which comes with version 3.6.1 of python.
I was given various directions for installing pip.
None seemed to work.
For example,
link https://packaging.python.org/tutorials/installing-packages/
says that I can run:
python -m pip install -U pip setuptools
Get a whole bunch of errors. It might amount to: no module named queue.
Similar errors happen when I download the file they mentioned (get-pip.py) and run it from python.
Now, when I look at directions for installing queue, some point me to use pip. But when I try to install pip, it is complaining that queue is not there....
Hmmm...?
Now what?
ERROR:
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\__init__.py", line 11, in <module>
File "C:\Program Files (x86)\Ampps\python\lib\logging\config.py", line 30, in <module>
import logging.handlers
File "C:\Program Files (x86)\Ampps\python\lib\logging\handlers.py", line 28, in <module>
import queue
ModuleNotFoundError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "getpip.py", line 20061, in <module>
main()
File "getpip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "getpip.py", line 82, in bootstrap
import pip
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\__init__.py", line 26, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\utils\__init__.py", line 22, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\__init__.py", line 13, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\dictconfig.py", line 22, in <module>
File "C:\Program Files (x86)\Ampps\python\lib\logging\handlers.py", line 28, in <module>
import queue
ModuleNotFoundError: No module named 'queue'
From the format i see here.
Firstly, pip is an installer basically what you've confused yourself with is that pip = queue which is not the case. Pip is just a packager that helps you install packages. Queue is a different module
For your case here Queue is a part of multiprocessing module so you just put this at the top of your code:
from multiprocessing import Queue
and you do not need to add import pip into your code
hope that explained things better for you :)
This line:
python -m pip install -U pip setuptools
means use pip to upgrade the installations of pip and setuptools. Only works if you already have pip - which you probably do. It is a useful step to make sure your install environment is up to date, though.
pip does in places use queue. Note it's been renamed between python2 and python3 - if you have py3, which you claim, you have queue (it was Queue in py2). So I wonder if there's a version mismatch in something.
Windows installs always create problems. You might be safer installing and experimenting with a virtualenv so your experiments don't mess up the python install from the package you mention - ampps. There are plenty of notes on that elsewhere on stackoverflow... e.g. Python and Virtualenv on Windows
pip is already included in 3.6.1, but it is in subfolder Scripts.
it is not automatically a part of the path variable.
you have to change directory and run pip or you can change environment variable so that the location of pip becomes part of the path search.

Emacs, python: Run "sudo pip install names" to install

Emacs 24.5
Python 2.7.12
If I start simple (Hello world) python script from shell - is OK. But if start more difficult script then return error:
python myscript.py "some_params"
ATTENTION! https://pypi.python.org/pypi/names/ package is requred to randgen human names.
Run "sudo pip install names" to install.
Traceback (most recent call last):
File "myscript.py", line 6, in <module>
import secretary
File "my_another_script.py", line 5, in <module>
import names
ImportError: No module named names
You need to install the external libraries you are using. names in this case is an external library that you need to install to make your script work.

Python doesn't see installed module entity.rfc3413.oneliner

thank you in advance for help.
Here is an issue, I use module pysnmp with pyasn1, I am using this example:
http://pysnmp.sourceforge.net/quickstart.html , and getting an error:
# python snmp.py
Traceback (most recent call last):
File "snmp.py", line 1, in <module>
from pysnmp.entity.rfc3413.oneliner import cmdgen
File "/home/user_name/rrd_poller/pysnmp.py", line 5, in <module>
ImportError: No module named **entity.rfc3413.oneliner**
Other question is why it refers to entity.rfc3413.oneliner but not to pysnmp.entity.rfc3413.oneliner . Also, I checked
/usr/local/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/__init__.py
These server has two versions of python installed one is in /usr/bin/ other in /opt, When I do:
which python
I get:
/opt/python/python/Python-2.7.5/python # which is correct location
Modules are installed:
#python -c "help ('modules')"
Gives:
pysnmp and pyasn1
Looks like Python tries to resolve your module (pysnmp.py) as top-level pysnmp package component so it can't get past it to reach 'entity' sub-package which is absent in your module. That's why renaming your script to a non-conflicting name might help.
Use pysnmp
pip install -U pysnmp
[root#localhost]# python
Python 2.7.5
>> from pysnmp.entity.rfc3413.oneliner import cmdgen
>>

AttributeError: 'module' object has no attribute 'wraps'

I am trying to get Django running on a shared hosting account for which I have ssh access, but I have been having issues getting it working. When I first tried running django-admin.py, I received an error about the module 'functools' being missing. I had the hosting company install the functools package, but now I get the following traceback when I try to run django-admin.py.
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
File "/usr/local/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/core/management/__init__.py", line 3, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/local/lib/python2.6/optparse.py", line 90, in <module>
from gettext import gettext
File "/usr/local/lib/python2.6/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/usr/local/lib/python2.6/locale.py", line 98, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
I opened a support ticket and was told by the company that they reinstalled Python 2.6, but that didn't change anything. I also tried with 2.4, which is also installed on the machine, but that resulted in the earlier ImportError: No module named functools error.
Does anybody have any ideas?
A likely cause is something shadowing the stdlib functools module. Do you have a functools.py alongside the main script (manage.py)? See what import functools; print functools.__file__ prints, inside manage.py (before any of the other imports.) If it doesn't print /usr/local/lib/python2.6/functools.py, there's probably a file shadowing the standard library module. If it does print that, something is wrong with that file, reinstalls notwithstanding.
this solution worked for me .
mv /usr/lib/python2.7/site-packages/pip* ./
yum reinstall python-pip
sudo pip install django
or try an another solution .
its too risky and this might not be a safest solution.but it worked fine for me .
uninstall pip.
pip uninstall pip
if you installed by get-pip.py .
python -m pip uninstall pip setuptools
navigate to the path.
/usr/lib/python2.7/site-packages/
and find out two pip directories pip and pip-6.0.8.dist-info.
remove both pip and pip-6.0.8.dist-info.
then try again.
yum install python-pip
or
python get-pip.py

Categories

Resources