PyBuilder "ModuleNotFoundError: No module named" when running - python

I'm playing around with PyBuilder and I must be either missing something, or misunderstanding how PyBuilder works. In my test application, I'm importing the pdfrw library. I had installed it via pip and everything was working fine. However, I decided to try starting over in a new venv and not installing via pip first to see if PyBuilder pulled in the dependency. When I run pyb it runs fine, no errors, but when I try to run the code from the target directory it gives me an error of "ModuleNotFoundError: No module named pdfrw".
I'm used to using Maven and Gradle for Java development but this is my first foray into dependency management for Python. Can anyone let me know if I'm just misunderstanding what PyBuilder can do or if I'm just missing something in the configuration? Here's a copy of the simple build.py script that pyb is referencing:
from pybuilder.core import init, use_plugin
use_plugin("python.core")
use_plugin("python.install_dependencies")
default_task = "publish"
#init
def initialize(project):
project.depends_on('pdfrw')
Any help would be greatly appreciated.
Thanks,
Chris

Try to use
pyb install_dependencies
According to http://pybuilder.github.io/documentation/tutorial.html#WritingUnitTests

Related

ImportError: cannot import name 'global_sdk_config' from 'aws_xray_sdk'

Through Tox i am trying to run a unit test in my local. The test seems to fail, giving me the following error:
from aws_xray_sdk import global_sdk_config
E ImportError: cannot import name 'global_sdk_config' from 'aws_xray_sdk'
Looking at the package installed in virtaul environment created by tox, i see the following files in aws_sray_sdk :
Upon closer insepection, i see when i had created virtual environment myself (without tox) and run pip install aws-xray-sdk, i also see sdk_config.py
and version.py in package aws_sdk_xray as shown below:
Can someone please help me with this.
In the screenshot you show us tox running a Python 3.7 environment, and in the following screenshots you show us the site-packages of Python 3.6.
These do not match.
You need to make sure you inspect the correct tox environment.

How to properly import libtcod in PyCharm?

I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff:
but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.
Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?
Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
It's a python port of libtcod.
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote

No module named admin_view_permission, CircleCI?

When I run my Django project on CircleCI I get the following error: "ModuleNotFoundError: No module named 'admin_view_permission'"
The project runs with no problems locally on my computer. I added the module admin_view_premissions, to settings, from this page: https://github.com/ctxis/django-admin-view-permission
Then I ran "pip install django-admin-view-permission", and it worked fine. The migration also did not have any problems.
Does anyone know why CircleCI is not able to find the module?
Thank you for your time!
I had to write the package in the Pip-file by using: pipenv install django-admin-view-permission

Python: Custom package installation not importing module

I'm having a problem with this package that I installed in Python 3.5. After installing it, I try to run requestProxy.py but it won't import any of its own packages. Here's what I did, and what's happening.
I cloned it and created a private repo using these instructions.
I installed in an activated virtualenv, created without using sudo, using:
pip3 install -e HTTP_Proxy_Randomizer
Terminal said it installed ok.
I can find the egg link in my virtualenv's site-packages folder, but when I try to run the main file, it says:
from project.http.requests.parsers.freeproxyParser import freeproxyParser
ImportError: No module named project.http.requests.parsers.freeproxyParser
I had to write a setup.py for the package, which didn't seem to come with its own. I came up with:
setup(name='HTTP_Request_Randomizer',
version='1.0',
description='HTTP Proxy Request Randomizer',
package_dir={'project': 'project','http':'project/http',\
'requests':'project/http/requests','errors':'project/http/requests/errors',\
'parsers':'project/http/requests/parsers','proxy':'project/http/requests/proxy'},
packages=['project','http','requests','errors','parsers','proxy']
Here's the package structure:
pip3 freeze
gives me:
Complete output from command git config --get-regexp remote\..*\.url:
fatal: bad config file line 4 in /home/danny/.gitconfig
----------------------------------------
Error when trying to get requirement for VCS system Command "git config --get-regexp remote\..*\.url" failed with error code 128 in /home/danny/Documents/HTTP_Request_Randomizer, falling back to uneditable format
Could not determine repository location of /home/danny/Documents/HTTP_Request_Randomizer
Django==1.9.7
## !! Could not determine repository location
HTTP-Request-Randomizer==1.0
mysqlclient==1.3.7
So I want to have requestProxy.py install the other necessary packages and not fail at line 1. I'm sure this is a problem with my implementation and not the original author's coding. I was experimenting with this package a couple of weeks ago before I was aware of virtualenvs or pip install -e, and just copied it manually to site-packages. It worked then. Now I understand the concepts to do it more cleanly, but I can't get those to work.
It feels as though I have done something wrong with my git config or with my package_dir structure in setup.py, perhaps?
I've been pythoning for maybe a month and have a lot to learn. I normally find what I need on Stack Overflow without having to bother anyone, but after trying everything with this, I really need some help. Any advice much appreciated.
I figured it out. I was using Ninja IDE, and even though I entered the virtualenv for the project and restarted, it still wasn't recognizing it. I was able to run it from the terminal, and also in Pycharm and Liclipse.

Failure to install ndg-httpsclient or maybe I'm doing the solution wrong

I'm new to python and have a little experience with VS, C# and WPF.
My question might seem similar to some asked questions, but I tried several of the suggested solutions (that worked for others), and yet it doesn't work for me.
I'm trying to build a simple WPF application that will send http requests.
The solution structure is as follows:
Solution MyApp
Project 1 <This is the startup project>
GUImodul.py
queryStringBuilder.py
<This project uses IronPython env for the WPF support>
Project 2
QuerySender.py (includes two classes)
<This project uses Python 3.4 env, only in this one I managed installing the "requests" package which I need for sending the query>
When I try to run this I get an error "No module named ndg.httpsclient.ssl_peer_verification", even though I only import from project 2 a class that doesn't contain any import from "requests" (it only creates an instance of the other class there that does have such import).
When I try to install ndg-httpsclient using pip, I get "Command python setup.py egg_info failed with error code 1".
Things I tried so far:
Adding "-X:FullFrames" to the debug properties of both projects
(re)installing steuptools with from ez_setup.zip
As said - ndg-httpsclient is installed for Python34
Using the "import requests" command only within the class NOT imported to Project1 (the one with IronPython env)
Tried installing a newer(?) version of urllib3
So...
I just might be doing something fundamentally wrong in this solution, which in this case I wish someone to help me understand what it is.
Otherwise, any idea what can I try next to make this thing work?
If you read the fine print, ndg-httpsclient is incompatible with Python 3, as it was developed for Python2.7 . That's probabably the root cause.
RE: Why is Python 3.0 not backward compatible?

Categories

Resources