ImportError importing Web3 using pythonanywhere - pythonanywhere

Using Pythonanywhere, I successfully installed Web3 using the Bash console like so, with no errors:
pip3.8 install --user web3
My code has the following at the beginning:
import json
from web3 import Web3
When I run the file, I get an error as follows:
ImportError: cannot import name 'scrypt' from 'Crypto.Protocol.KDF' (/usr/lib/python3.8/site-packages/Crypto/Protocol/KDF.py)
The same code works perfectly fine on my Pycharm setup.
Any suggestions on fixing this issue?

I solved the problem by updating pycryptodom:
pip3 install --upgrade --user pycryptodom
Everything works fine now.

I use pythonanywhere all the time. Try pip3 install web3 --user. The second error seems to be with pycryptodome. Try pip3 install pycryptodome --user as well.

pip3 install --upgrade --user pycryptodome

Related

AttributeError: module 'OpenSSL.SSL' has no attribute 'TLS_METHOD'

When trying to import scrapy in my Jupyter Notebooks via Anaconda (Windows), I get this error, which I haven´t been able to solve. I'm working with Python 3.
What I did till now:
pip install Scrapy
pip install pyopenssl
import scrapy
and I get the following error:
TLS METHOD ERROR
Tks for your help.
Gisselle
I Have installed latest version of cryptography which worked for me . You can try it
pip install cryptography

RASA X running issue: Make sure to start Rasa X with valid data and valid domain and config files

enter image description here I am trying to installing Rasa. I run this command rasa init. It's working fine. But when I am trying to run this command rasa x it throws an error as shown in the above image(link). One solution I have found is to remove domain_path=domain_path from the x.py file which can be found in such a path: C:\Users\Admin\anaconda3\envs\Myenv\Lib\site-packages\rasa\cli\x.py . Even though the other solution I've heard is to downgrade the version of Python and pip. Versions are (Rasa Version: 2.8.1, Python Version:3.7, pip version: 20.2) But still, I can't get rid of it. If anybody has a solution, please help.
To solve this issue, please follow the below steps:
pip install rasa==2.8.1
check rasa --version
then install
pip install rasa-sdk==2.8.1
Install this version rasa-x==0.39.3
pip install rasa-x==0.39.3 --extra-index-url https://pypi.rasa.com/simple
Some know errors:
ImportError: cannot import name ‘RowProxy’ from ‘sqlalchemy.engine’ try running pip install SQLAlchemy==1.3.22 should fix it.)
And, if you get an error not being able to import yaml then run pip install pyyaml.

Ansible and docker-compose pull / up -d

I'm trying to run theses commands :
docker-compose pull
docker-compose up -d
docker-compose -f other_file.yaml pull
docker-compose -f other_file.yaml up -d
Here's my Ansible code for this specific task :
- name: Run docker-compose
docker_compose:
project_src: {{ my_project_path }}
files:
- docker-compose.yaml
- other_file.yaml
I'm getting the error bellow
Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on managed's Python /usr/bin/python3.
Please read module documentation and install in the appropriate location.
If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6).
The error was: No module named 'docker'
The fact is that the python interpreter is set up in the ansible.cfg as /usr/bin/python3 which is the good one.
The version of python3 installed is 3.6.9 and the python module "docker" is installed.
Any idea on where this error comes from ? Been reading documentation, and others post all day.
Thanks !
Finally understood why the problem occured.
I was installing the python library with pip3 install <lib> the fact is that it will not work if you're using sudo to run some modules in Ansible because sudo pip3 is different from pip3 on its own.
So quick solution ? sudo pip3 install docker docker-compose

Installing python modules in vs code not working

i am trying to install some module like: "praw" and "discord" but after using this command: pip install praw in vs code's terminal and after when i run the file, i got a error saying that No module named 'praw' i have searched the entire internet that how to install a module in vs code and about this error. pls help if you know.
Thanks
If you have python3 you could try py -3 -m pip install praw or python3 -m pip install praw
edit: If this doesn't works in vscode then try running cmd as admin.

RASA chatbot rasa.core.policies.ensemble.InvalidPolicyConfig: Module for policy ‘MemoizationPolicy’ could not be loaded

I’ve got this error, just following the « Getting Started with Rasa » tutorial
So I’ve typed:
sudo pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
which seems to work fine but when I’ve typed:
sudo rasa init
I’ve got a lot of errors among them:
rasa.core.policies.ensemble.InvalidPolicyConfig: Module for policy ‘MemoizationPolicy’ could not be loaded. Please make sure the name is a valid policy.
I faced the same problem when I tried using - rasa init. This is solved by paying attention to 2 things. When you try to install rasa using - pip install rasa in a virtual environment. This install latest python version, in my case this was 3.8, but the problem was that TensorFlow support was not available for 3.8, So I will suggest-
conda create --name rasa python=3.6
For anaconda or you could also create a virtual environment. Now use
pip install rasa
Now you will notice TensorFlow==1.15.1 will be installed. For rasa to work we will need TensorFlow==1.15.0
pip uninstall tensorflow
pip install tensorflow-cpu==1.15.0
if you want CPU support only otherwise,
pip install tensorflow==1.15.0
This worked for me.
In fact, it was a dependencies nightmare.
So what I’ve done to get a rasa chatbot up and running:
Reinstall dask (but I’m not sure this step is mandatory)
sudo pip3 install "dask[complete]"
Downgraded my version of pandas
sudo pip3 install pandas==0.19.2
Upgraded tqdm
sudo pip3 install -U tqdm
Upgraded OpenAI gym
sudo pip3 install -U gym
Et voilà!
This is a library mismatch error. It is Rasa version error, you most probably installed Rasa 1.7.0 or 1.8.0 you need to downgrade to 1.6.0. After downgrading it solved my problem.
Commands to run :
pip uninstall rasa
After you uninstall, re-install rasa by running the commands
pip install rasa==1.6.0
or
python -m pip install rasa==1.6.0
Try using rasa-x rather than rasa library:
virtualenv -p 3.6.8 rasaenvx
rasaenvx\Scripts\activate
pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
rasa init --no-prompt