AttributeError: 'module' object has no attribute 'MutableSet' - python

I installed BitTornado without root access by downloading the zip and running command 'pip install -e path/to/bittornado/'. The installation was successful but when I tried using it for downloading the file, the following error occurred --
AttributeError: 'module' object has no attribute 'MutableSet'.
The following screenshot has the details.
I'm new to Python. If someone know what's happening, please help. Thanks in advance.

BitTornado only supports python3 (and not python2.x). The specific error is due to a change in python3 which makes imports absolute by default (unless the relative import syntax is used) -- as such it is importing the BitTorando.Types.collections module for import collections.
I'd suggest making a python3 virtualenv and installing BitTornado there. (Or if you want a system-wide installation, use pip3 install ...)

Related

Trying to import GitHub module

I'm trying to import https://github.com/chrisconlan/algorithmic-trading-with-python in my code. I've never imported anything from GitHub before and have looked at various other questions that have been asked on Stack Overflow regarding this problem but it just doesn't work. When I try to run the 'portfolio.py' code for example I keep getting a ModuleNotFound error for 'pypm'. What exactly is the correct way to import such a module or the whole GitHub directory?
I'm working with Visual Studio Code on Windows.
You will need to pip install the module. In your case the command you would need to run is python -m pip install -U git+https://github.com/chrisconlan/algorithmic-trading-with-python. Once you have done that you need to find the name of the module. You can do this with pip list. Find the name of the module you just installed.
Then you just stick import <module name> at the top of your code with the rest of your imports.
What i used to do in this is to clone the repository on the folder where are installed the python's packages. This is useful when you do not want to use the pip cmd tool, keeping the pip's cache memory under control.

XBRL Module Not Recognized

I've downloaded the XBRL module using pip install. But the Python interpreter says "No module named 'xbrl'", despite the XBRL being present via C:\Program Files\Python36\Lib\site-packages. How do I resolve this issue so I can run XBRL in Python?
I think you need to install python-xbrl.
Th easiest way is with pip :
pip install python-xbrl
Do you have two Pythons? It could be you installed the module with one pip/python and tried to import with another python.
Anyway there is nothing to use: the module xbrl.py doesn't have any content. This xbrl.py is unusable, you should look for a different implementation.

NameError: name 'json' is not defined

Trying to import Json, my command is pip install json.
I'm working on windows 8.1
The error i'm getting in command prompt is
Could not find a version that satisfies the requirements json <from versions:>
No matching distribution found for json.
and the error i'm getting on pycharm is
NameError: name 'json' is not defined
I tried importing numpy and it worked just fine .
I also did check Pip "Could not find a that satisfies the requirement"
and Could not find a version that satisfies the requirement <package>
Edit : Referred also to this link Python 3.5.1 : NameError: name 'json' is not defined and getting an error that sudo is not recognized
If it's not defined in your code, you need to import it. This is exactly the same as any name in Python; you can't use something until you have defined it.
import json
I have also encountered a similar issue, pip failing to install json and math modules (using python 3.x).
Finally, I discovered that some modules you simply do not have to install - they are already BUILT-IN. :)
Of course, you still have to add "import json" at the top of your .py file.
Hope this helps somebody.
Use the command as simplejson instead of json like below,
pip install simplejson
If the above command also throwing an error Use the following command
easy_install simplejson
easy_install works sometimes if pip cannot serve the request.

TypeError: '>=' not supported between instances of 'NoneType' and 'str'

I have been able to install pycrypto as follows, followed the given answer.
But when I debug the project, then getting the following issue which seems to be related Crypto.
ModuleNotFoundError: No module named 'winrandom'
aut\token.py line 3 is
from jose.jwt import get_unverified_claims
UPDATE:1
Then, I have run pip install winrandom and get the following error.
TypeError: '>=' not supported between instances of 'NoneType' and
'str'
UPDATE:2
When I rung the proposed command pip install --proxy http://XXXX:80 git+https://github.com/dlitz/pycrypto.git with proxy(required) in the working environment, then I get a connection refused error as follows.
It seems this is a common issue with pycrypto. This is a bug, but the project doesn't seem to be updated in the last couple years.
Digging over the issue, (https://github.com/andrewcooke/simple-crypt/issues/17)
It seems the poblem is solved by doing an edit to the import statement in crypto\Random\OSRNG\nt.py:
import winrandom
to
from . import winrandom
As Vinny mentioned, this issue is known and solved in Pycrypto, but PyPi still delivers an old release of Pycrytpto. You can instead install the latest release directly from the GitHub repository by using:
pip install git+https://github.com/dlitz/pycrypto.git

editing code of a python module

Running pymatlab on my machine results in
Exception AttributeError: "'MatlabSession' object has no attribute 'engine'" in > ignored
after the command session = pymatlab.session_factory() is run.
How to fix this problem has been discussed already here:
Running MATLAB from Python
It looks like one line of code in the sessionfactory.py script in the pymatlab module has to be changed in a minor way. The problem I have is that the pymatlab module which is installed on my machine is in .egg form and it doesn't look like it is possible to change the code directly with a text editor. Any suggestions on how to do that?
Thanks
If you use easy_install, check
How do I forbid easy_install from zipping eggs?
If you prefer pip (and you probably should), check
pip: “Editable” Installs, i.e.
pip install -e pymatlab

Categories