I tried to make a AI for minecraft using python's library minerl.
import gym
import minerl
env = gym.make('MineRLObtainDiamond-v0')
But for some reason I get this error:
self.shape = ()
AttributeError: can't set attribute
Can someone tell me why I get an error?
I run it on the latest python version, python 3.9.7, on Pycharm and I use Windows 10 build 19402.
You have too new gym installed. Run the command:
pip install gym==0.19 and try again.
https://github.com/minerllabs/minerl/issues/620
Related
I am not able to install pyfolio in my local jupyter environment.
After !pip install pyfolio, the success message comes, but when I run 'import pyfolio as pf'
the following error throws.
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
Can anyone suggest how to install pyfolio?
The main Python Package Index (pypi) entry for pyfolio here is no longer supported as described here.
Following the suggestions there, you may want pyfolio-reloaded (repo: here).
Following the directions at the repo, try running in a cell in a new notebook the following:
%pip install pyfolio-reloaded
Restart the kernel and and then try:
import pyfolio as pf
Open3d was not available on the anaconda navigator so I installed it using the anaconda prompt with the conda install command.
I wanted to try a basic code for Ball Pivoting Algorithm from http://www.open3d.org/docs/release/tutorial/geometry/surface_reconstruction.html
import open3d as o3d
import os
import sys
bunny = o3d.data.BunnyMesh()
gt_mesh = o3d.io.read_triangle_mesh(bunny.path)
gt_mesh.compute_vertex_normals()
but even running the first lines I get the error
Attribute error: module ‘open3d’ has no attribute ‘data’
I’ve no idea why this is.
Support for open3d.data has been added in version 0.15. Upgrade the Open3d version and then try this API.
Release note: https://github.com/isl-org/Open3D/releases/tag/v0.15.1
I've installed web3 today via pip install web3 and since then I've been trying to import web3 into the current working file without any success.
No matter what I do, I get "Unable to import 'web3'.
Pip list finds web3 (web3 5.19.0).
Code in the file:
import web3
from web3 import Web3, HTTPProvider, TestRPCProvider
infura_url = 'URL'
web3 = Web3(Web3.HTTPProvider(infura_url))
isConnected = web3.isConnected()
blocknumber = web3.eth.blockNumber
Update
I know what's wrong, pip installs packages in C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages meanwhile python is looking for the packages in C:\Users\USER\AppData\Roaming\Python\Python39
You Don't need the first import and it is effecting you'r code cause you'r variable called web3, just delete
import web3
and it should work
pip list is showing web3 library, after figuring out I found that it is a problem of vs code python editor. Run the following code irrespective of editor error message
if run successfully
from web3 import Web3
print(Web3)
It will give output
<class 'web3.main.Web3'>
Then it mean it has some vs code python editor problem but you can ignore warning and use web3 for coding purpose
You Don't need the first import and it is effecting you're code cause you're variable called web3, just delete
import web3
and for webSocket use it:
Web3(Web3.WebsocketProvider(infura_url))
and for http use it:
Web3(Web3.HTTPProvider(infura_url))
This is a problem with Visual Studio Code.
I tried to open the code with PyCharm and it is working properly.
you must install visual c ++ build tools // desktop development with c ++ // then you install web3 in the console and it will not give you an error
https://visualstudio.microsoft.com/visual-cpp-build-tools/
This sounds like an issue with your local version. I would try quitting the app and try again.
Some suggested that it works despite of the error. But in my case it wasn't. So, the solution for me was installing web3 globally on my local system, outside of the virtual env using pip3 install web3 command. I'm using python3 on Ubuntu 20.04 LTS.
delete first line of code.
also delete import HTTPProvider or use code below
web3 = Web3(HTTPProvider(infura_url))
instead of
web3 = Web3(Web3.HTTPProvider(infura_url))
you should set up a virtual environment to avoid the type of issue you just described (packages being installed in different locations on your machine)
check this out for more info:
https://docs.python.org/3/library/venv.html
heres my quick guide
open up a terminal, navigate to the root directory of your project and set up a virtual environment
python3 -m venv /path/to/new/virtual/environment
to activate your virtual environment run the following command
source /path/to/new/virtual/environment/bin/activate
now run pip install web3
now that your virtual environment is activated and you've installed python3 you should be able to run your file
python name_of_file.py
I had the same situation.
The solution is to rename the python file from Web3.py to something else.
i am a newbie in Python and want to try to tweet using python using this code, but after i run it, in python shell said that
from twython import Twython
ModuleNotFoundError: No module named 'twython'
Can someone help what's wrong with my code?
Welcome to Python family! When a module is first imported, Python searches for the module and if found, it creates a module object, initializing it. If the named module cannot be found, a ModuleNotFoundError is raised.
As a beginner, you should learn how to install a package in Python by going through the tutorial: https://packaging.python.org/tutorials/
Next, you should follow the installation guide in
https://twython.readthedocs.io/en/latest/usage/install.html
In the command prompt, you should run
pip install twython
Observe if any error pops up during the installation.
To see if Twython works correctly, start Python in the command prompt,
python
In the Python environment, run the following command:
>>> from twython import Twython
If Twython is installed correctly, you should not see the ModuleNotFoundError.
ModuleNotFoundError means that the module is not installed. Sometimes may be the module is installed but it is installed in a place where python does not look for it. In your case I feel you have not installed twython.
Open command prompt and type the following command
pip install twython
This should install the twython and after this if you run your file the error will not appear.
Check this out for more information on twython https://pypi.org/project/twython/
Firstly, you should try again pip install command,
Also:
If you are using an different place such as Pycharm or Jupyter or Anaconda, you must reinstall that module in that working environments
If you are using python's own ide, try add your current python path to system path
Re-read usage of your module
I have got a strange issue.
I am now using graphlab/numpy to develop a project via Pycharm 5. OS is Mac OS 10.11.5. I created a p2.7 virtual environment for the project. Programme runs well. But after I install ipython, I can no longer import graphlab and numpy correctly.
Error message:
AttributeError: 'module' object has no attribute 'core'
System keeps telling that attribute ‘core' and 'connect' are missing. But I am pretty sure that they can be found in graphlab/numpy folders, and no duplicates.
Project runs all right in terminal. Now I have to uninstall ipython. Then everything is ok again.
Please kindly help.
Please remember that console applications and GUI application do not share the same environment on OS X.
This also means that if you install a Python package from the console, this would probably not be visible to PyCharm.
Usually you need to install packages using PyCharm in order to be able to use them.
Upgrading pip itself then reinstalling worked for me