Python Forum
using self-developed modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using self-developed modules
#11
Just for info:
I stated that I had changed the "system variables" of my win10 in the correct way. Fyi, this is a printout of the output of "echo %PATH%:

Output:
C:\Users\actname>echo %path% C:\Program Files (x86)\Common Files\Oracle\Java\javapath; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; C:\WINDOWS\System32\OpenSSH\; C:\Program Files (x86)\EaseUS\Todo Backup\bin; C:\Program Files\dotnet\; C:\Program Files (x86)\dotnet\; C:\Program Files (x86)\Pinnacle\Shared Files\; C:\Program Files (x86)\Pinnacle\Shared Files\Filter\; G:\Pythonmodules; ......... C:\Users\actname\AppData\Local\Programs\Python\Python37-32\Scripts\; C:\Users\actname\AppData\Local\Programs\Python\Python37-32\; C:\Users\actname\AppData\Local\Microsoft\WindowsApps; G:\Pythonmodules;
Note: I edited the output manually to make it better readable.

As you can see, the "G:\Pythonmodules" folder, that contains the to-be-imported module, is listed as being part of the "User Variables" (after line with ".........") and of the "System Variables"(before line with "........."). But when I display in Python "pprint (sys.path)", the folder does not show up.
Strange!
Reply
#12
(Aug-30-2019, 04:16 PM)wlp Wrote: But when I display in Python "pprint (sys.path)", the folder does not show up.
Strange!
No it's not strange,there is no connection between Environment Variables(OS) and sys.path(Python).
Example i have a folder C:\nc in System Variables Path.
Same code as before saved as eggs.py in this folder.
# eggs.py
def f1(x):
    x = x + 1
    return x
C:\Users\Tom
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import eggs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'eggs'

# Most add nc to sys.path,so python find it
>>> import sys
>>> sys.path.append(r'C:\nc') # Only temporarily added in this session 

# Now it work
>>> import eggs

>>> eggs.f1(799)
800
As i explain link before in this post.
Using site will add folder permanent to sys.path,this mean that dos not need to add a folder to System or User Variables Path.
As long as Python is System Variables as eg you have here:
C:\Users\actname\AppData\Local\Programs\Python\Python37-32\Scripts\;
C:\Users\actname\AppData\Local\Programs\Python\Python37-32\
Reply
#13
I have been experimenting a bit more. I got it working now!

I deleted all my additions to the System Variables "path" and to the User Variables "path". And I added a new variable called PYTHONPATH (pointing the my General Use folder) to the System Variables. After a Win10 "restart" I did "run" "main.py" from the normal dedicated folder, and python now finds my "selfwrittenmodule.py" in the "General Use" folder.

Did I do something wrong earlier? Maybe. Or was the old (and maybe misconfigured Python) cause the problem? That's possible too, I don't know. Though I was convinced that I had tried the PYTHONPATH already earlier and that it did not function at that occasion.

But that it now functions is the only thing that really counts!

Thank you very much for your help!

Now that we are in contact, I still use IdleX as a simple editor and testing tool. I do not need a complete and complex Development Environment (I am not a professional Python programmer. I only use it to ease my own tasks. But sometimes I think that IdleX could provide more assistance and functionality. Can you recommend another, easy to use tool that is more functional (most important: "easy to use")?
Reply
#14
(Aug-31-2019, 01:45 PM)wlp Wrote: Can you recommend another, easy to use tool that is more functional (most important: "easy to use")?
PyScripter is very easy to use and quite good,also Thonny is okay.

Look at my tutorial VS Code from start,some setup before use,but it has lot to offer.

cmder for a really good shell for Windows.
I use also ptpython in cmder look really good,and easy to use as Autocompletion show up automatically.
This combo is what i used showing examples in this post.
[Image: 0L9O33.jpg]

Last JupyterLab as a lot can be done in browser that most editor will struggle with showing inside there editor.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Developed App in VS2019 - Help with pyinstaller fioranosnake 0 1,573 Nov-11-2019, 09:12 PM
Last Post: fioranosnake
  Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 bmohanraj91 6 8,352 May-25-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020