Installing urllib3 for a non-standard Python version - python

The server I'm coding on has a Python 2.4 binary available in /usr/bin/ and a Python 3.0 binary available in $HOME/bin/. I need to install urllib3 for use with Python 3, but easy_install of course uses the python available system-wide. easy_install installed urllib3 just fine for Python 2.4. I tried to run it with Python 3 but it complains about missing modules:
$ ~/bin/python3.0 /usr/bin/easy_install --prefix=/home/web/local urllib3
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
How might I work around this? Note that I did install pip with easy_install but pip is missing too many dependencies, so I'm stuck with easy_install.

The error you're getting because easy_install isn't installed for Python3.
You want to first install easy_install for Python3 by following the instructions here: http://pypi.python.org/pypi/distribute#installation-instructions
$ curl -O http://python-distribute.org/distribute_setup.py
$ python3.0 distribute_setup.py
Then you'll be able to run ~/bin/easy_install, or easy_install-3.0 to install urllib3:
$ easy_install-3.0 urllib3
Now! Note that urllib3 doesn't officially support Python 3.0… 3.2 is the first supported version, and in general Python 3.2 is the version most library authors are targeting these days, so it might be worth considering switching to 3.2 (not to mention that it's much faster, and other happy things).

Related

ModuleNotFoundError: No module named 'cryptography'

these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.

ModuleNotFoundError: No module named 'ruamel'

I'm using a Kubernetes inventory builder script found here: https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/inventory_builder/inventory.py
On line 36, the ruamel YML library is imported using the code from ruamel.yaml import YAML. This library can be found here: https://pypi.org/project/ruamel.yaml/
On my OSX device (Mojave 10.14.3), if I run pip list, I can clearly see the most up to date version of ruamel.yaml:
If I run pip show ruamel.yaml, I get the following output:
I'm running the script with this command: CONFIG_FILE=inventory/mycluster/hosts.ini python3 contrib/inventory_builder/inventory.py 10.0.0.1 10.0.0.2 10.0.0.4 10.0.0.5
Bizarrely, it returns the following error:
Traceback (most recent call last):
File "contrib/inventory_builder/inventory.py", line 36, in <module>
from ruamel.yaml import YAML
ModuleNotFoundError: No module named 'ruamel'
I have very little experience with Python, so don't understand how this could be failing. Have I installed the library incorrectly or something? From the documentation on the ruamel.yml project page, it looks like the script is calling the library as it should be.
Thanks in advance
In my case, I was installing this with pip3 install ruamel.yaml, and it was puting the package in /usr/local/lib/python3.9/site-packages/, but the python3 binary on the machine was pinned to Python 3.7, so trying to import that module was sending the ModuleNotFoundError message.
What helped to fix this, was to install the module with python3 -m pip install ruamel.yaml, running pip via the python3 binary makes sure it runs on the same version, in this case 3.7, and gets installed via the correct version number site-packages.
pip is set to point to the Python 2 installation. To install the library under Python 3, do pip3 install ruamel.yml.
you're using python 3 and want to use the package that is with python 2. Go to the directory where your python 3 is, navigate to Scripts and use the pip in there to install the needed library.
This helped me (adding version number to python):
CONFIG_FILE=inventory/mycluster/hosts.yaml python3.6 contrib/inventory_builder/inventory.py ${IPS[#]}
[python 3.10.x].
There is no package called ruamel.yaml
what worked is pip install ruamel-yaml

invalid syntax when run pylint

the following is the stack trace, please suggest
my python version is 2.7
-----------------
pylint
Traceback (most recent call last):
File "E:\Python27\Scripts\pylint-script.py", line 11, in <module>
load_entry_point('pylint==2.0.0', 'console_scripts', 'pylint')()
File "E:\Python27\lib\site-packages\pylint-2.0.0-py2.7.egg\pylint\__init__.py"
, line 17, in run_pylint
from pylint.lint import Run
File "E:\Python27\lib\site-packages\pylint-2.0.0-py2.7.egg\pylint\lint.py", li
ne 75, in <module>
import astroid
File "E:\Python27\lib\site-packages\astroid-2.0.1-py2.7.egg\astroid\__init__.p
y", line 59, in <module>
from astroid.exceptions import *
File "E:\Python27\lib\site-packages\astroid-2.0.1-py2.7.egg\astroid\exceptions
.py", line 13, in <module>
from astroid import util
File "E:\Python27\lib\site-packages\astroid-2.0.1-py2.7.egg\astroid\util.py",
line 148
yield from islice(iterator, size)
^
SyntaxError: invalid syntax
my python version is 2.7
pylint 2.0.0 requires at least Python 3.4.1
The last version that supported Python 2.7 was 1.9.2. So, your fix is to downgrade to 1.9.2.
The specific error message you're seeing is because yield from was added to the language in Python 3.3, so code that uses it can't run in 2.7. But there are probably lots of other errors. After all, the only reason developers drop 2.7 support is so they can use new language features.
If you install it with pip install pylint or py -m pip install pylint using Python 2, it should automatically install 1.9.2 instead of 2.0.0—or, failing that, the installation should fail instead of appearing to succeed. (When I test it myself, that's exactly what happens.)
However, installing with an old version of pip, might cause this problem. If so, upgrade your pip and setuptools. (You definitely want at least pip 10 and setuptools 30… but generally you want the latest version available, so just let it do that.)
py -m pip install --upgrade pip setuptools
If that was your problem, you should have seen a warning, like You are using pip version 6.0, however version 18.0 is available. That warning doesn't look hugely important, but it is—especially if you're staying on 2.7 (or, similarly, if you like to follow the bleeding edge and install beta versions of Python).
Installing with easy_install can definitely cause this. If that's your problem, just stop using easy_install and start using pip.
If you installed it manually instead of by using pip, then you have to do the version checking manually as well. If you have a good reason for doing that, download 1.9.2 and install that manually instead.
At any rate, however you got thing into this situation, you should be able to fix it by uninstalling pylint and then running:
py -m pip install pylint==1.9.2
1. According to its own documentation, it specifically supports 3.4, 3.5, and 3.6. It may also support 3.7 despite saying it doesn't—later versions definitely do, and of course future versions will support even newer versions of Python. But definitely not 2.7.

Django Taggit Module Installation Error: No module named setup tools

The title basically explains it all.
I am running Windows 8 (windows 7 was previously installed... If it helps with answering) and am using Python 2.7.
Upon using the code:
python setup.py install
I am getting this error:
C:\Users\Nicholas\Desktop\taggit>python setup.py install
Traceback (most recent call last):
File "setup.py", line 52, in
from setuptools import setup
ImportError: No module named setuptools
Any help?
Thanks in advance
Nicholas
You need to install setuptools, which allows packages to be configured for your Python installation. It is not included with the default Python installer.
From this link you can download Windows installers for many Python packages (I have linked it directly to setuptools). Make sure you download the version that matches your Python installation.
in Python 3:
pip3 install setuptools
And in Python 2.x:
pip install setuptools

how to add json library

i am new to python, on my Mac, when i issue command
User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
I get error on json. how to add this library? i'm using 2.5 (the default came with leopard)
You can also install simplejson.
If you have pip (see https://pypi.python.org/pypi/pip) as your Python package manager you can install simplejson with:
pip install simplejson
This is similar to the comment of installing with easy_install, but I prefer pip to easy_install as you can easily uninstall in pip with "pip uninstall package".
AFAIK the json module was added in version 2.6, see here. I'm guessing you can update your python installation to the latest stable 2.6 from this page.
You can also install json-py from here http://sourceforge.net/projects/json-py/

Categories