(Python beginner here) I created an application called myPackage and it was working fine on Python2.X. I used to run it like this:
While located in /users/username/myPackage
python -m myPackage ... (other arguments)
This used to work in Python2.X, but now I just installed python3.10 and I get
no module name myPackage
What should I do? If I run this from /users/username/ it works, but I am wondering if there are any “best practices” or if there is another way to get this to work from /users/username/myPackage like it used to.
With 3.10.9 on Windows, I just ran
py -3.10 -m X in directory …/X. X has main.py, which is needed for -m to work with package directory. I don’t know why you get a different result. Did main.py disappear? Does it have a 3.x syntax error?
The behaviour of Python 2 nd Python 3 are basicly the same for the
I keep my personal code in its own area; for me that’s
/Users/cameron/lib/python so for, say, my
cs.myke package it lives
/Users/cameron/lib/python/cs/myke/.... Then my
envoronment variable has
/Users/cameron/lib/python in it. With that
environment variable I can go:
python -m cs.myke ......
Cameron Simpson firstname.lastname@example.org
Excellent, thank you! This is exactly what I needed.