Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with reading a path
#21
(Jan-05-2019, 03:47 AM)snippsat Wrote: In Python 3 it's okay to use file,in python 2 it was not.

Gorramit, no one told me Python 3 was going to be backwards incompatible with complaints about newbie code.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#22
(Jan-05-2019, 03:47 AM)snippsat Wrote: Are you using Anaconda3 or miniconda?
Error:
error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\...
The error comes from miniconda,but you have also have C:\Users\gonca\Anaconda3. You know that Anaconda3(full version 1400+ packages) and miniconda3(0 packages have to install with conda or pip) are different standalone versions?
ichabod801 Wrote:Also, file is a really bad variable name. file is a built-in type in Python
In Python 3 it's okay to use file,in python 2 it was not.
# Python 2.7 >>> file <type 'file'> # Python 3.7 >>> file Traceback (most recent call last): File "<interactive input>", line 1, in <module> NameError: name 'file' is not defined
I have used file many times in Python 3,even if old habits sometime hit in and tells that's is wrong when it really is not Undecided


I'm using Anaconda 3, is this problem of reading the path, related with this Ide?
Is there any other ide's that cannot have this tipe of errors?
Reply
#23
(Jan-05-2019, 02:16 PM)gkiller007 Wrote: I'm using Anaconda 3, is this problem of reading the path, related with this Ide?
Then error should never point to miniconda3.
In your previous post:
11             orig = cv2.imread(r'C:/Users/gonca/Desktop/landscape' + file)
---> 12             orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)
Here the file get read,but then a error occurs in:
Error:
error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\...
Also here is the problem not reading of file but a problem in OpenCV(3.4.2) that's install in miniconda3.
If you start from Andonda3 and error occurs in miniconda3,then something is mixed up and wrong.
Anaconda3 and miniconda3 are stand alone versions and should never be mixed together.
Reply
#24
(Jan-05-2019, 02:38 PM)snippsat Wrote:
(Jan-05-2019, 02:16 PM)gkiller007 Wrote: I'm using Anaconda 3, is this problem of reading the path, related with this Ide?
Then error should never point to miniconda3. In your previous post:
11 orig = cv2.imread(r'C:/Users/gonca/Desktop/landscape' + file) ---> 12 orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)
Here the file get read,but then a error occurs in:
Error:
error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\...
Also here is the problem not reading of file but a problem in OpenCV(3.4.2). If you start from Andonda3 and error occurs in miniconda3,then something is mixed up and wrong. Andonda3 and miniconda3 are stand alone versions and should never be mixed together.


So, maybe i messed up on the instalation of Anaconda 3 right?
What do you suggest? unnintall everyting and install again? what version should i install?
Reply
#25
(Jan-05-2019, 02:42 PM)gkiller007 Wrote: So, maybe i messed up on the instalation of Anaconda 3 right?
What do you suggest? unnintall everyting and install again? what version should i install?
It's easiest for you to use the full Python 3.7 version of Anaconda.
Under install make sure that you add to Path if want this to be your main Python version.
[Image: hvHkZO.jpg]
Restart Pc after install.

Now test in for cmd,it should point to Anacond3 from anywhere in cmd not miniconda3.
If point to miniconda3 most remove from Windows Path.

It shall look like this,i have to do it from Anacond3 folder because Python 3.7(python.org),is my my main Python version in Windows path.
G:\>cd anaconda3

G:\Anaconda3>python -V
Python 3.7.1

# Point to Anaconda3
G:\Anaconda3>python -c "import sys; print(sys.executable)"
G:\Anaconda3\python.exe

G:\Anaconda3>cd Scripts

# Point to Anaconda3
G:\Anaconda3\Scripts>pip -V
pip 18.1 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

# Point to Anaconda3
G:\Anaconda3\Scripts>conda -V
conda 4.5.12
Like this it should work for you from anywhere in cmd when Anaconda is in Windows Path.
When i talk about Windows Path i mean Environment Variables Path.
So for you it should be pointing to Anaconda3 eg C:\Anaconda3 and C:\Anaconda3\Scripts.
If see miniconda3 in Path remove it.
[Image: GUgLry.jpg]
Reply
#26
(Jan-05-2019, 03:26 PM)snippsat Wrote:
(Jan-05-2019, 02:42 PM)gkiller007 Wrote: So, maybe i messed up on the instalation of Anaconda 3 right? What do you suggest? unnintall everyting and install again? what version should i install?
It's easiest for you to use the full Python 3.7 version of Anaconda. Under install make sure that you add to Path if want this to be your main Python version. [Image: hvHkZO.jpg] Restart Pc after install. Now test in for cmd,it should point to Anacond3 from anywhere in cmd not miniconda3. If point to miniconda3 most remove from Windows Path. It shall look like this,i have to do it from Anacond3 folder because Python 3.7(python.org),is my my main Python version in Windows path.
G:\>cd anaconda3 G:\Anaconda3>python -V Python 3.7.1 # Point to Anaconda3 G:\Anaconda3>python -c "import sys; print(sys.executable)" G:\Anaconda3\python.exe G:\Anaconda3>cd Scripts # Point to Anaconda3 G:\Anaconda3\Scripts>pip -V pip 18.1 from G:\Anaconda3\lib\site-packages\pip (python 3.7) # Point to Anaconda3 G:\Anaconda3\Scripts>conda -V conda 4.5.12 
Like this it should work for you from anywhere in cmd when Anaconda is in Windows Path. When i talk about Windows Path i mean Environment Variables Path. So for you it should be pointing to Anaconda3 eg C:\Anaconda3 and C:\Anaconda3\Scripts. If see miniconda3 in Path remove it. [Image: GUgLry.jpg]


I've done it all and it has gone well

Now when i run my project i'm missing cv2 module, who do i install it?

from sklearn.decomposition import NMF
from matplotlib import pyplot as plt
import cv2
import numpy as np
import os
import sys
import statistics
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-7128546282f5> in <module>
      1 from sklearn.decomposition import NMF
      2 from matplotlib import pyplot as plt
----> 3 import cv2
      4 import numpy as np
      5 import os

ModuleNotFoundError: No module named 'cv2'
Reply
#27
Do:
python -m pip install --user numpy -I
pip install opencv-python
Test that it work:
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 cv2
>>> cv2.__version__
'3.4.5'
>>>
Look at Anaconda and other ways to run Python.
Reply
#28
(Jan-05-2019, 06:34 PM)snippsat Wrote: Do:
python -m pip install --user numpy -I pip install opencv-python
Test that it work:
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 cv2 >>> cv2.__version__ '3.4.5' >>>
Look at Anaconda and other ways to run Python.

I ran it and this was the result:


Error:
(base) C:\Users\gonca>python -m pip install --user numpy -I Collecting numpy Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/ Could not find a version that satisfies the requirement numpy (from versions: ) No matching distribution found for numpy
Reply
#29
Try only.
pip install opencv-python
The do test import cv2 and see if get any errors.
Reply
#30
(Jan-05-2019, 09:11 PM)snippsat Wrote: Try only.
pip install opencv-python
The do test import cv2 and see if get any errors.


Now it gives another error


Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/9a/de/901d0546a2465b94be8574bffb4610f57f0fe5c0f2141b7ba43eb8ebac26/opencv_python-3.4.5.20-cp37-cp37m-win_amd64.whl (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel file reading problem max70990 1 907 Dec-11-2022, 07:00 PM
Last Post: deanhystad
  Loop reading csv file problem faustineaiden 1 1,583 Dec-11-2021, 08:40 AM
Last Post: ibreeden
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,230 Sep-09-2021, 01:25 PM
Last Post: Yoriz
Exclamation Path sacn problem lucky511 10 3,936 Jun-24-2021, 12:09 PM
Last Post: Axel_Erfurt
  Subprocess.Popen() not working when reading file path from csv file herwin 13 15,181 May-07-2021, 03:26 PM
Last Post: herwin
  Strange Problem when reading from excel faryad13 3 2,414 Nov-04-2020, 03:48 PM
Last Post: DeaD_EyE
  problem about maze path finder Simurg 2 1,971 Aug-16-2020, 01:10 PM
Last Post: Simurg
  Reading integers from a file; the problem may be the newline characters JRWoodwardMSW 2 1,984 Jul-14-2020, 02:27 AM
Last Post: bowlofred
  Problem reading data from file player1681 2 3,770 May-22-2020, 08:57 AM
Last Post: player1681
  Problem with reading and writing to file. darktitan 2 2,310 Jul-20-2019, 06:06 PM
Last Post: darktitan

Forum Jump:

User Panel Messages

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