I wrote a simple Python interface for working with the Pushwoosh notification service a while back, which is at https://github.com/Astutech/Pushwoosh-Python-library and I've finally gotten around to publishing it so it can be installed using Pip. This is the first time I've published a Python library to PyPi and I'm in a bit of a muddle.
Trying to install it brings up the following error:
Collecting pushwoosh
Using cached pushwoosh-1.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-5m3jj7uu/pushwoosh/setup.py", line 17, in <module>
with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
File "/usr/lib/python3.4/codecs.py", line 896, in open
file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-5m3jj7uu/pushwoosh/DESCRIPTION.rst'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5m3jj7uu/pushwoosh
It looks like some kind of path related issue. I'm not sure that pushwoosh.py is in the correct location. But if I move it to pushwoosh/pushwoosh.py, and add a pushwoosh/__init__.py fileI then need to import it as follows:
from pushwoosh.pushwoosh import Pushwoosh
This is obviously not ideal. From the documentation I can't see where I've gone wrong. What directory layout should I be using?
EDIT: I have now resolved the issue with DESCRIPTION.rst, but unless I move the pushwoosh.py file to a pushwoosh folder and add an __init__.py file, installing the library doesn't actually install pushwoosh.py so it doesn't work. How can I amend it so I can import it like this?
from pushwoosh import Pushwoosh
Figured it out in the end. It works if you put the file inside the module_name folder as __init__.py.
You could've just put this into your __init__py file.
from pushwoosh import Pushwoosh
This lets you make the import like this without packing everything into the init.py file itself.
from pushwoosh import Pushwoosh
for a nice explanation check out this post http://mikegrouchy.com/blog/2012/05/be-pythonic-__init__py.html
Related
I got a project which consists of Python and C++. I don't understand all of it but in order to compile and run everything I run an included BAT file. I have already installed the dependencies needed. Now when I run the script, I get this:
MainProcess - [INFO] os_utils: Disabling idle sleep not supported on this OS version.
world - [ERROR] launchables.world: Process Capture crashed with trace:
Traceback (most recent call last):
File "C:\work\pupil\pupil_src\launchables\world.py", line 118, in world
from plugin_manager import Plugin_Manager
File "C:\work\pupil\pupil_src\shared_modules\plugin_manager.py", line 15, in <module>
from video_capture import Base_Manager, Base_Source
File "C:\work\pupil\pupil_src\shared_modules\video_capture\__init__.py", line 36, in <module>
from .file_backend import FileCaptureError, FileSeekError
File "C:\work\pupil\pupil_src\shared_modules\video_capture\file_backend.py", line 13, in <module>
import av
File "C:\Users\XXX\AppData\Local\Programs\Python\Python36\lib\site-packages\av\__init__.py", line 9, in <module>
from av._core import time_base, pyav_version as __version__
ImportError: DLL load failed: The specified module could not be found.
It couldn't find pyav? But if I run:
C:\Users\XXX\Downloads>pip install av-0.3.1-cp36-cp36m-win_amd64.whl
Requirement already satisfied: av==0.3.1 from file:///C:/Users/XXX/Downloads/av-0.3.1-cp36-cp36m-win_amd64.whl in c:\users\anton\appdata\local\programs\python\python36\lib\site-packages
I already have it installed. What am doing wrong here?
If I open ...site-packages\av__init__.py" I can see this:
from av._core import time_base, pyav_version as __version__
is it something here?
I suspect that the module has successfully installed, but is dynamically linked against FFMPEG. You can obtain built distributions of FFMPEG from their website (https://www.ffmpeg.org/download.html). They provide both statically linked and dynamically linked builds, though it is going to be the dynamically linked one that is providing the dll's you need. Looking at my own copy of PyAV, it seems that the current release version (3.4.2) is the one that it is linked against.
When you download it, it will have a name like ffmpeg-date-build-win64-shared. In the bin directory, you will find all the relevant DLLs. You can either add this directory to the PATH, or more easily, copy the DLLs to your python location.
I am attempting to install this https://github.com/jordens/pyflycapture2 python binding on my Windows machine. The readme only has instructions on how to do it for Linux systems, but I imagine the library should still work.
I am able to run "python setup.py install" and it seems to successfully complete, but when I try to run "python test_flycapture2.py" I get this error:
C:\Users\clinic\Desktop\pyflycapture2>python test_flycapture2.py Traceback (most recent call last):
File "test_flycapture2.py", line 20, in <module>
import flycapture2 as fc2
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
This seems to imply that flycapture2 wasn't installed correctly. When I instead just open a python session and do "import flycapture2" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
Have I done something wrong with the installation process or does pyflycapture2 just not work with Windows?
A dumb solution that's worth a try. There are chances that the DLL are searched directly from where you're starting the python script. So if you have the dll somewhere on your computer, copy it along where you have your test_flycapture2.py.
But given the fact that the setup.py file has a whole bunch of absolute paths in there, I would not place my hopes too high. You can also try to install FlyCapture 2 at the exact same path, run python setup.py bdist_wheel (you will need to install wheel first with pip) in the pyflycapture2 folder, and see if that succeeds.
If it does, try installing the generated wheel (that will be in dist/ subfolder) by doing pip install dist/pyfly....wheel and test again.
Hope this helps
I'm answering this mostly because I found another post where the same question had been posted but the original problem was never answered.
How do I run an installed Python module on Windows?
In the comments, the original poster says that it suddenly started working. I found that the solution was simply to restart my computer. I have now attempted this on two computers and this worked for both of them.
I am very new to python and have been figuring out how to install modules.I have been trying to install the SOAPpy module and have only had success with the required modules fpconst, wstools, and setuptools(not mentioned as required, but still ended up being required).
I am getting an error when I try and install the SOAPpy module.
Traceback <most recent call last>:
File "...\setup.py", line 43, in module <module>
__version__ = load_version()
File "...\setup.py", line 35 in load_version
execfile(filename, d.__dict__)
IOError: [Errno 2] Unable to load the version number (no such file or directory):
'...\\src\\SOAPpy\\version.py'
Not sure what i should do to fix this.
Any help is greatly appreciated!
Looking at SOAPpy's setup.py file, it tries to import SOAPpy.version. This doesn't work if you're calling it from somewhere else. Try running it directly in the SOAPpy directory because Python adds your current working directory to sys.path. For example:
cd C:\Users\eclaird\Download\SOAPpy\ # The folder with setup.py
python.exe setup.py install
Thanks for the help.
I eventually found what the issue was. I had to get some other required modules for the install to work, also the tar file I got was missing directories, so I found the completed version on Github.
I have a project from which I would like to generate two separate python packages. I want to install these packages using pip.
In answers to this previous question, the general recommendation was to write two setup.py scripts: Multiple projects from one setup.py?
So I tried a structure like this:
/myproject
setup_foo.py
setup_bar.py
/mypackage1
/mypackage2
...
In setup_foo.py I set the script_name parameter:
from distutils.core import setup
setup(name = 'foo',
version = '2.0.0',
...,
script_name = 'setup_foo.py')
(I also tried the below without the parameter - according to the documentation it defaults to sys.argv[0])
I create foo-2.0.0.tar.gz using
python setup_foo.py sdist
But when I pip install foo-2.0.0.tar.gz, I get an error like this:
Unpacking .../foo-2.0.0.tar.gz
Running setup.py egg_info for package from file:///...foo-2.0.0.tar.gz
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/var/folders/wj/jv7n2pmn5d1g1jjx6khc8bx80000gn/T/pip-v3dujq-build/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory:
'/var/folders/wj/jv7n2pmn5d1g1jjx6khc8bx80000gn/T/pip-v3dujq-build/setup.py'
Am I missing some way of instructing pip to use setup_foo.py? Or should I place two scripts, both named 'setup.py', in separate directories?
The question is why you put those projects into one directory. My recommendation would be to properly separate them, and then add them to a shared virtualenv via "setup.py develop -U". Been there, done that, works beautifully.
Otherwise, your next problem will be sharing a "setup.cfg", "MANIFEST.in", etc. In general you'll have a lot of unnecessary pain, each time you break assumptions of setuptools / distribute.
I suppose you chose the above structure so both packages are in the python path automagically, the "develop -U" makes it explicit, and quoting "import this":
Explicit is better than implicit.
It looks like setuptools does not support setup scripts that are not named setup.py, contrary to distutils. I think it would be best to report the bug to the setuptools (bugs.python.org/setuptools) and distribute (on bitbucket) developers.
I'm currently trying to make cx_freeze to work on a Solaris workstation I have to work with, in order to make an executable from a Python script I have. Problem is, I'm not administrator of this machine, and installation of cx_freeze requests write to site-packages, which is read-only for me.
So, obviously, I get this error:
creating /usr/local/lib/python2.6/site-packages/cx_Freeze
error: could not create '/usr/local/lib/python2.6/site-packages/cx_Freeze': Read-only file system
And if I try to run it anyway, it fails:
bash-3.00$ python /home/xxxx/cx_freeze-4.2.3/cxfreeze --target-dir cx_dist src/p_tool.py
Traceback (most recent call last):
File "/home/xxxx/cx_freeze-4.2.3/cxfreeze", line 5, in <module>
main()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/main.py", line 187, in main
silent = options.silent)
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 91, in __init__
self._VerifyConfiguration()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 371, in _VerifyConfiguration
self._GetInitScriptFileName()
File "/home/xxxx/cx_freeze-4.2.3/cx_Freeze/freezer.py", line 283, in _GetInitScriptFileName
raise ConfigError("no initscript named %s", name)
cx_Freeze.freezer.ConfigError: no initscript named Console
Obviously, this is linked to the failed installation. So, here's my question:
Without installation of virtualenv, could I avoid the writing to site-packages, and make cx_freeze to execute from my home folder?
EDIT I had a look at site.py documentation, and PYTHONPATH filling should be equivalent to use of site-packages. So my question is now more something like: what is the path to be added to PYTHONPATH, so that cx_freeze could be executed from any location?
Notes:
I would like to avoid to deal with virtualenv, as I'm already struggling to understand the executable tools...
I saw this question, but this still requires access to site-packages folder, plus it's not user-specific;
I tried adding the following path to PYTHONPATH, but this does not work: /home/xxxx/cx_freeze-4.2.3/build/lib.solaris-2.10-sun4v-2.6;
I'm also trying to use PyInstaller but have dependency problems (and the administrator is not really helping me).
This works like a charm for me :
$ python setup.py install --home=$HOME
Run in the source directory of cx_freeze found on the Sourceforge download page.