resolving issues with path - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: resolving issues with path (/thread-17166.html) |
resolving issues with path - aster - Mar-31-2019 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 worksbut 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: 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: 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 RE: resolving issues with path - snippsat - Mar-31-2019 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. RE: resolving issues with path - aster - Mar-31-2019 I solved it adding #! python3 on top of the script and installing py I lost a few hours for this issue... RE: resolving issues with path - snippsat - Apr-01-2019 (Mar-31-2019, 11:57 PM)aster Wrote: I solved it adding #! python3 on top of the script and installing pyNo 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.
RE: resolving issues with path - aster - Apr-01-2019 if i don't put the #! python3 i getQuote:File "C:\Users\vincenzo\Miniconda3\Lib\site.py", line 177as 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 getQuote:Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32 I am sure that this shouldn't be so complex and a python script should be run without any hassle from command line RE: resolving issues with path - snippsat - Apr-01-2019 (Apr-01-2019, 09:08 AM)aster Wrote: as far i understood this is due to windows using python 2 to run my scriptAre 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 getThat'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\ScriptsAlso Path shown over should be where arrow are in image,here pointing to 3.7. Environment Variables Path Restart Pc. 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. |