I am a C# developer and have decided to jump into Bitcoin programming using Python in Ubuntu, so I don't know much about python at the moment.
I downloaded some example code and at the top it says
import bitcoin
It seems I need to somehow setup pybitcointools as a bitcoin module to use with Python based on the book Mastering Bitcoin 2nd Edition.
However, I can't seem to figure out how to install pybitcointools. I know it's not installed because my first example code gives the error:
oshirowanen#oshirowanen:~/Desktop$ python3 ./key-to-address-ecc-example.py
Traceback (most recent call last):
File "./key-to-address-ecc-example.py", line 2, in <module>
import bitcoin
ImportError: No module named 'bitcoin'
What have I already tried?
sudo aptitude install python-pip
sudo pip install pybitcointools
and I get a message saying that it has installed successfully.
The package you're looking for has an empty description on PyPI and installs nothing when you install it.
If you click on the Homepage link, it's a GitHub repo containing nothing but a README file saying:
I really don't have time to maintain this library further. If you want to fork it or use it despite lack of maintenance, feel free to clone locally and revert one commit.
So, whatever this package used to provide before December 2017, it no longer does.
Options:
Just accept that the book is obsolete and therefore useless. Even if it's only a year old. (Somewhere I still have a book that's mostly about guesses about what's going to be in Java 1.1… nowadays, I don't usually buy books unless they're about ancient-enough-to-be-stable technology.)
If you really want to, you can do what that README suggests. But honestly, if you don't know enough about Git to fork the repo and revert the blanking commit, enough about pip to install from a Git repo, and enough about Python to update and maintain the code, that's not going to do you any good.
You could try searching for other forks of the library on Github, but trying to figure out if one of them is being maintained by someone who knows what they're doing just by looking over the repos is pretty much impossible if you don't know enough about what they're doing.
You could try to find some Python Bitcoin programming community mailing list, IRC channel, forum, chat site, whatever and ask people there what they're doing. Stack Overflow is definitely not the right place to ask that. The lists and channels on Python's Community site might at least be able to point you in the right direction. Or maybe the Software Recommendations Stack Exchange, but be sure to read their help first and see if it's on topic.
Related
I was trying to add the Strings library into the Robot Framework Interpreter folder in PyCharm, where first it showed me error
Command errored out with exit status: 1
So, I googled out this issue first, and this link suggested me to delete 'strings.py' file from the libraries. I did so and now nothing is working.
Anything I do now, it shows error of "ModuleNotFoundError: No module named 'string'".
I could not even install string using
pip install strings
command.
Whatever I try to do with pip, now shows this error.
Can anyone please suggest me the solution for this?
I am using Python version 3.10.
Several notes:
The library in question is 9 years old, is not maintained, is known by the author to be buggy, was written as a joke, and does not contain anything useful. There is no good reason why you should be trying to install it for your project. If you think you need it for something, then you have some other misconception that needs to be cleared up.
The link you found did not tell you to delete strings.py from "the libraries". It said something about deleting string.py - notice, no s at the end - from a local project folder. The reason for this is because that name conflicts with the library name. The page author's own source file, named string.py, sought to import the standard library file string.py (as it clearly says import string in the screen shot), but it cannot - because it finds itself first. This is a common problem for new Python users.
DO NOT EVER MANUALLY EDIT THE CONTENTS OF YOUR INSTALLATION DIRECTORY ON THE ADVICE OF SOME RANDOM WEB PAGE.
Ideally, don't ever do it at all. That content is not intended to be touched. Installers exist for a reason. If for some incredibly specific reason you feel the need to do this, make sure you have backups of everything and that you are 100% sure you can restore everything to its initial state if anything goes wrong.
The person writing that web page was incorrect. The installation error had nothing to do with the string.py file.
The actual cause of the problem is that the package is broken and cannot be installed properly on anyone else's machine. Again, this is no big loss as there is no use for the package anyway.
The reason it is broken is that the setup script for the package tries to import the code that's being installed, in order to get version and author information. This seems to work locally, but fails for everyone else.
To reiterate: the person writing that article wrote nonsense. (I'm not surprised; the page formatting is awful and the grammar isn't particularly great either.) Looking further, it appears that the entire website is authored by the one person, who is clearly just trying to self-promote (with a Youtube channel as well) while lacking the necessary expertise. Browsing around the rest of the site a bit, I see articles that are pedantic and not very insightful, and occasionally inaccurate - but all very SEO optimized.
I recommend ignoring that website entirely.
To reiterate: the string module comes with your Python. You cannot reinstall it with pip - not with the strings package you found, nor any other package. Your options are:
Find the correct string.py contents (possibly from a backup, assuming you thought to make a backup before deleting something from an installation directory) and restore them. This is the official repository for the reference implementation of Python. You might be able to find it in there somewhere. I don't recommend trying. There is a lot to go through and it is possible to damage things further.
Reinstall Python completely.
The error that you are getting is because you deleted the string.py file. There is no string module to be imported from PyPi. This is why pip install string doesn't work. Restore the deleted file as it is not the cause of your problem.
If you try to install Strings library it will fail because you are using Python 3.10 and the Strings library that you want to import and install is quite old and not supported for this Python version. Therefore you get the ModuleNotFoundError: No module named 'strings' that you see in the link that you attached.
For the setup.py file from the library I see that it recommends using Python 3.3, so I will recommend you to use that version of Python if you want to use this specific library.
Please note that the link that you provided is probably in case that you have created your own string.py file.
I solved this question by deleting any __pycache__ folder in the project directory.
I'm a newbie of coding, and now I'm trying to study Python.
When I've registered on PyPI, and try to publish source code on it, the fault comes out:
Your selection [default 1]:
1
Username: johncheung
Password:
Registering nester to https://pypi.python.org/pypi
Server response (403): You are not allowed to store 'nester' package information
What I've all done is followed by books. What's wrong?
There is already a package called nester. You don't own it, so you don't have permission to change it.
If you don't have some original, useful code to publish, don't publish it. You can learn Python just fine without pushing to pypi.
The package nester already exists and you probably aren't the package owner. So you aren't allowed to publish new versions of it, as that could replace a known package with something else entirely.
As Dietrich's answer says:
If you don't have some original, useful code to publish, don't publish it. You can learn Python just fine without pushing to pypi.
If you just want to get your code out there, put it on GitHub, GitLab, Bitbucket or a similar code hosting service. PyPI is only for when your code is really useful to a wider audience as a library installable by pip.
If you think that is the case:
If your package is unrelated, choose a different name.
If you want to change something about the existing nester package, see whether and how the respective project accepts contributions or ask the author about that.
I would like to be able to use the services that the Blockcypher module provides for my programme, however i have (at least i think) downloaded the correct module package but cant get it to integrate with my Python on my Computer. I am fairly new to python so I have no idea on where to even start tackling this problem.
Modules, regardless of where you've got hold of them, will be searched for in the sys.path. If nothing is found there, they will be looked up in the current directory.
When you download some code directly it will be a good first guess to place it in the directory of the script from where you are using the download. If it's just a .py-file, place it there. If it's an archive with a directory, then place the directory there (not the files).
Generally, you should prefer installing modules via a package manager such as pip or conda. Such package managers take care of placing modules properly for usage with your Python installation from wherever you will write your script. They also provide support for updating these modules to newer versions later.
Update: If you cannot make anything from this remarks, you should first read the section on modules in the Python tutorial, or even work thru the full tutorial or thru a good book (or any other ;) to get a smooth entry into the friendly world of Python programming.
Update (2023): The Dive Into Python link above is outdated, so here is the updated link to this great resource:
https://diveintopython3.problemsolving.io
I think it's still the best beginner's resource, but, well, here are many more:
https://wiki.python.org/moin/IntroductoryBooks
So I have a Python package – it’s all set up on PyPI, and on GitHub, no problem. This is something I’m relatively familiar with.
What is unknown to me is: the notion of installing a CMake script as part of the python package install process. The python package in question is a development tool – you use it to preprocess some of your C/C++/Obj-C/Obj-C++ source files and generate some predefined macros in a header – and it works well when it’s wrapped in a CMake macro (for example like so) and executed as part of a proper chain of dependencies.
For one, I am not sure how to approach this, as there seem to be significant differences between the setuptools sandbox stance and distutils’ willing systems-level installer integration – and then even if I did know how to go about setting things up correctly in setup.py, I can’t find a good precedent on where a CMake script pertaining to a Python package might live.
All thoughts and insights on the matter are welcome.
It took me a while to understand your question. If I understand correctly, what you are trying to do is provide the IodSymbolize.cmake in the standard installation location of cmake so that other users/projects who rely on your software(symbolizer) can use it in their build process. I think you are thinking in a good direction, trying to provide services for end users of your package. Good question!
Here is my understanding of how things work in the cmake world.
Say I am an end user who wants to use "symbolizer" executable. What I would do is
find_package(symbolizer). This would try to figure out the location of the executable and it would set certain variables which can be used in the build process.
You need to provide Findsymbolizer.cmake file.
Please take a look at : http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
Also look at the Find*.cmake files provided in /usr//share/cmake/Modules directory if you are Unix/Linux platform.
Once the Findsymbolizer.cmake file is working properly, send it to the cmake mailing list for review. Once accepted it can be packaged in the next release of cmake. Then your module is usable with cmake. Hope I answered your question. Please update if you need more info.
I am trying to install via pip install a python module. But when I do it, it gives me this:
RuntimeError: Required library Boost not found.
Now, I have already downloaded boost. I put it in program files/boost (hopefully that is how it's done because the boost web page doesn't give much detail on the installation except to download and extract). So I am not sure what the problem is. I have tried to do cd program files/boost, but that doesn't work either. The instruction from the documentation is pretty vague too.
First time I am doing this, so I can't tell if what I am doing is dreadfully wrong or not.
Now, I have already downloaded boost. I put it in program files/boost (hopefully that is how it's done because the boost web page doesn't give much detail on the installation except to download and extract)
No, that's not how it's done, and that's your problem.
Also, I don't know where you got the idea that the Boost web page doesn't give much detail on installation. There's a huge Getting Started document.
Of course that documentation tells you how to build C++ programs that you're writing against Boost; it doesn't tell you how to convince Python to find it for modules that depend on Boost.Python. That's in the Boost.Python docs.
Also note that Christoph Gohlke's unofficial Windows Python Binaries includes a boost.python package, which installs all the Python-side runtime stuff for you, which makes it a bit easier.
This isn't simple. (It's a lot simpler on Unix systems (including Macs), where, as long as you install a C or C++ library into some standard path, every other program can find it.) But I doubt anyone is going to be able to provide a better tutorial in a StackOverflow answer than the one in the official docs, so you're just going to have to read them.