Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
resolving issues with path
#1
I am on windows 10, python and all his modules has been installed with miniconda, .py files added to PATHEXT, bin folder and python added to PATH

If i run a script with C:\Users\vincenzo\Miniconda3\python.exe D:\cloud\Programmi\bin\wrap.py text it works

but if i run wrap text i get error:

Traceback (most recent call last): File "D:\cloud\Programmi\bin\wrap.py", line 6, in import pyperclip, click ImportError: No module named pyperclip

If i run

import importlib
print(importlib.util.find_spec('pyperclip'))
i get:

Output:
ModuleSpec(name='pyperclip', loader=<_frozen_importlib_external.SourceFileLoader object at 0x00000254796F94A8>, origin='C:\Users\vincenzo\Miniconda3\lib\site-packages\pyperclip\__init__.py', submodule_search_locations=['C:\Users\vincenzo\Miniconda3\lib\site-packages\pyperclip'])
I tried adding C:\Users\vincenzo\Miniconda3\lib\site-packages and C:\Users\vincenzo\Miniconda3\lib to PATH, nothing changed.

if i run:
import sys
for path in sys.path: print(path)
i get:
Output:
C:\Users\vincenzo\Miniconda3 C:\Users\vincenzo\Miniconda3\python37.zip C:\Users\vincenzo\Miniconda3\DLLs C:\Users\vincenzo\Miniconda3\lib C:\Users\vincenzo\Miniconda3\lib\site-packages C:\Users\vincenzo\Miniconda3\lib\site-packages\win32 C:\Users\vincenzo\Miniconda3\lib\site-packages\win32\lib C:\Users\vincenzo\Miniconda3\lib\site-packages\Pythonwin
Am i doing something wrong? How could i say to python where to find these missing modules?

added more info hoping someone can help me solve this
Reply
#2
Are you using Miniconda3 or Anaconda3?
It point to Miniconda3.

You have to know what python/pip run on command line or which version configured to run in editor.
I use both Python(python.org) set in Path and Anaconda3,and several other version.
So a test look like this.
# What version is set in Windows Path
C:\                                                                                                      
λ python -c "import sys; print(sys.executable)"                                                          
C:\python37\python.exe                                                                                   
 
# pip also point to 3.7                                                                                                        
C:\                                                                                                      
λ pip -V                                                                                                 
pip 19.0.3 from c:\python37\lib\site-packages\pip (python 3.7)                                           
   
# Test pyperclip                                                                                                      
C:\                                                                                                      
λ python                                                                                                 
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32        
Type "help", "copyright", "credits" or "license" for more information.                                   
>>> import pyperclip                                                                                     
Traceback (most recent call last):                                                                       
  File "<stdin>", line 1, in <module>                                                                    
ModuleNotFoundError: No module named 'pyperclip'                                                         
>>> exit()                                                                                               
   
# Install pyperclip                                                                                                    
C:\                                                                                                      
λ pip install pyperclip                                                                                  
Collecting pyperclip                                                                                     
  Downloading .......                                                          
Installing collected packages: pyperclip                                                                 
Successfully installed pyperclip-1.7.0                                                                   
 
# Test again                                                                                                        
C:\                                                                                                      
λ python                                                                                                 
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32        
Type "help", "copyright", "credits" or "license" for more information.                                   
>>> import pyperclip                                                                                     
>>> exit()
This mean that if i point interpreter to python 3.7 in editor it will work there to.

It will not work in Anaconda3(stand alone),have to install it there to.
G:\Anaconda3
λ python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyperclip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyperclip'
>>> exit()

G:\Anaconda3
λ cd Scripts\

G:\Anaconda3\Scripts
λ pip -V
pip 18.1 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

G:\Anaconda3\Scripts
λ conda -V
conda 4.6.8

G:\Anaconda3\Scripts
λ pip install pyperclip
Collecting pyperclip
Installing collected packages: pyperclip
Successfully installed pyperclip-1.7.0

G:\Anaconda3\Scripts
λ cd ..

G:\Anaconda3
λ python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyperclip
>>> exit() 

Have basic install tutorial here you can look at Windows | Anaconda | VS Code(now shipping with Anaconda in newer versions) they have dropped support for Spyder.
Reply
#3
I solved it adding #! python3 on top of the script and installing py

I lost a few hours for this issue...
Reply
#4
(Mar-31-2019, 11:57 PM)aster Wrote: I solved it adding #! python3 on top of the script and installing py
No need to add #! python3(added i think to work in Windows from 3.3-->) shebang in Windows.
If you use Spyder just configure to use right Python interpreter.
Also to make it easy have same Python interpreter run when you type python and pip on command line(cmd) or better use cmder.
Reply
#5
if i don't put the #! python3 i get
Quote:File "C:\Users\vincenzo\Miniconda3\Lib\site.py", line 177
file=sys.stderr)
^
SyntaxError: invalid syntax
as far i understood this is due to windows using python 2 to run my script

and then, funny stuff, is that if i run python i get

Quote:Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

I am sure that this shouldn't be so complex and a python script should be run without any hassle from command line
Reply
#6
(Apr-01-2019, 09:08 AM)aster Wrote: as far i understood this is due to windows using python 2 to run my script
Are you talking about running from Spyder now?
Check link i posted again about configure Python interpreter in Spyder.
(Apr-01-2019, 09:08 AM)aster Wrote: and then, funny stuff, is that if i run python i get
That's right if it start Miniconda3,and that is you manin Python version.
Check from cmd with,that it point to Miniconda3:
python -c "import sys; print(sys.executable)"

# Check also that pip point to Miniconda3 Scripts folder
pip -V

Quote:I tried adding C:\Users\vincenzo\Miniconda3\lib\site-packages and C:\Users\vincenzo\Miniconda3\lib to PATH, nothing changed.
That is not right,to add Miniconda to Windows Path it should be like this.
C:\Users\vincenzo\Miniconda3
C:\Users\vincenzo\Miniconda3\Scripts
Also Path shown over should be where arrow are in image,here pointing to 3.7.
Environment Variables Path
Restart Pc.
[Image: GUgLry.jpg]

Why did you choose Miniconda3 over Anaconda3(make all easier if you new to this).
Anaconda3 will ask if you want in to main Python version and add to Windows Path when install it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,316 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,151 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  mySQL Database error not resolving. cybertooth 2 3,119 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  pathlib: resolving a path that does not exist Skaperen 6 5,389 Sep-08-2018, 12:25 AM
Last Post: Skaperen
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,673 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908
  Help resolving error with webpy app bill349 1 3,135 May-18-2017, 09:36 AM
Last Post: bill349

Forum Jump:

User Panel Messages

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