ImportError when I change the directory in cmd - python-3.x

I am trying to import sklearn using cmd, I am changing the directory to a folder where I saved previous python files, however, I can't import sklearn in that particular folder and this is what I get:
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 14, in <module>
from .utils.fixes import signature
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\__init__.py", line 14, in <module>
from . import _joblib
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\_joblib.py", line 22, in <module>
from ..externals import joblib
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\__init__.py", line 119, in <module>
from .parallel import Parallel
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\parallel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\_parallel_backends.py", line 22, in <module>
from .executor import get_memmapping_executor
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\executor.py", line 14, in <module>
from .externals.loky.reusable_executor import get_reusable_executor
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\externals\loky\__init__.py", line 6, in <module>
from ._base import Executor, Future
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\externals\joblib\externals\loky\_base.py", line 22, in <module>
from concurrent.futures import wait, as_completed
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\__init__.py", line 17, in <module>
from concurrent.futures.process import ProcessPoolExecutor
File "C:\Users\VER\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\process.py", line 52, in <module>
from queue import Full
ImportError: cannot import name 'Full'
>>>

A file or folder is occupying a python file's namespace, for example, 'time.py'.
In this case, it is 'queue.py'
You need to remove it or you will not be able to import the module.
This is because python defaults to importing from the folder containing the program, and you must have a file overwriting 'queue.py' there.
I myself have experienced the error when attempting to import matplotlib into a file named 'copy', as a deep, deep dependency of matplotlib was named 'copy.py'

Related

ImportError: cannot import name 'NoReturn' PyTorch on MacOS Catalina

I'm having this weird problem in running torchvision in macOS Catalina. Here's the traceback
Traceback (most recent call last):
File "/Users/xdriyad/PycharmProjects/Resnet/main.py", line 1, in <module>
from model import ResNet50
File "/Users/xdriyad/PycharmProjects/Resnet/model.py", line 1, in <module>
import torch
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/__init__.py", line 573, in <module>
import torch.quantization
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/__init__.py", line 9, in <module>
from .quantize_fx import *
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/quantize_fx.py", line 1, in <module>
from .fx import Fuser # noqa: F401
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/__init__.py", line 1, in <module>
from .quantize import Quantizer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/quantize.py", line 2, in <module>
from torch._fx import (
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/__init__.py", line 89, in <module>
from .symbolic_trace import symbolic_trace, Tracer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/symbolic_trace.py", line 9, in <module>
from .proxy import Proxy, _create_proxy, TracerBase
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/proxy.py", line 7, in <module>
from typing import Tuple, Dict, Optional, Iterable, NoReturn, Any, Union, Callable
ImportError: cannot import name 'NoReturn'

how can i configurate python 3.7 with odoo 13 in pycharm windows 8

i tried to use odoo 13 src with python 3.7.4 on windows 8, i configured pycharm
script path : D:\odoo_13_projects\odoo13\odoo-bin
parameters : -r odoo -w odoo --db_host=localhost --addons-path=D:\odoo_13_projects\odoo13\addons
and i installed python requirements but always odoo didn't work
Traceback (most recent call last):
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\site-packages\werkzeug\serving.py", line 56, in <module>
from http.server import BaseHTTPRequestHandler
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\http\server.py", line 92, in <module>
import email.utils
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\utils.py", line 33, in <module>
from email._parseaddr import quote
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "D:\odoo_13_projects\odoo13\addons\calendar\__init__.py", line 4, in <module>
from . import controllers
File "D:\odoo_13_projects\odoo13\addons\calendar\controllers\__init__.py", line 4, in <module>
from . import main
File "D:\odoo_13_projects\odoo13\addons\calendar\controllers\main.py", line 6, in <module>
from odoo.api import Environment
File "D:\odoo_13_projects\odoo13\odoo\api.py", line 29, in <module>
from .tools.translate import _
File "D:\odoo_13_projects\odoo13\odoo\tools\translate.py", line 21, in <module>
from babel.messages import extract
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\site-packages\babel\messages\__init__.py", line 12, in <module>
from babel.messages.catalog import *
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\site-packages\babel\messages\catalog.py", line 15, in <module>
from cgi import parse_header
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\cgi.py", line 39, in <module>
from email.parser import FeedParser
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
ImportError: cannot import name '_has_surrogates' from 'email.utils' (C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\email\utils.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/odoo_13_projects/odoo13/odoo-bin", line 5, in <module>
import odoo
File "D:\odoo_13_projects\odoo13\odoo\__init__.py", line 113, in <module>
from . import modules
File "D:\odoo_13_projects\odoo13\odoo\modules\__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry
File "D:\odoo_13_projects\odoo13\odoo\modules\graph.py", line 10, in <module>
import odoo.tools as tools
File "D:\odoo_13_projects\odoo13\odoo\tools\__init__.py", line 10, in <module>
from .misc import *
File "D:\odoo_13_projects\odoo13\odoo\tools\misc.py", line 29, in <module>
import werkzeug.utils
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\site-packages\werkzeug\__init__.py", line 218, in <module>
from .serving import run_simple
File "C:\Users\Pc\AppData\Local\Programs\Python\Python37\lib\site-packages\werkzeug\serving.py", line 59, in <module>
import SocketServer as socketserver
ModuleNotFoundError: No module named 'SocketServer'
can any one help me please
Can you use python3.6?
because I am already using odoo 13 with python3.6 and I can't see any problem.
I think in your case there will be library mismatch for SocketServer because in python3.7 package name is socketserver.
I found the solution, I use two versions of python so I have to uncheck add content roots to PYTHONPATH and add source roots to PYTHONPATH in pycharm. Thank you guys
Do not use virtual interpreter pythons
that is okey
check this configuration
enter image description here

Python3 Virtual env unable to files that are saved in locations different from that of the virtualenv

I created a virtual environment for python3 in my home directory, I can run only those files that are saved in the home directory, if i try running a file stored at e.g., Desktop, it gives the following error:
(py3) gopi#gopi-inspiron:~/Desktop$ python detector_modulation_01.py
PyCBC.libutils: pkg-config call failed, setting NO_PKGCONFIG=1
Traceback (most recent call last):
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/compat/py3k.py", line 30, in <module>
import pickle5 as pickle
ModuleNotFoundError: No module named 'pickle5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "detector_modulation_01.py", line 1, in <module>
import numpy as np
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/core/overrides.py", line 9, in <module>
from numpy.compat._inspect import getargspec
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/compat/__init__.py", line 14, in <module>
from . import py3k
File "/home/gopi/py3/lib/python3.6/site-packages/numpy/compat/py3k.py", line 32, in <module>
import pickle
File "/usr/lib/python3.6/pickle.py", line 94, in <module>
from org.python.core import PyStringMap
File "/home/gopi/Desktop/org.py", line 1, in <module>
from pycbc.waveform import get_td_waveform
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/__init__.py", line 135, in <module>
import pycbc.fft.mkl
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/fft/__init__.py", line 17, in <module>
from .parser_support import insert_fft_option_group, verify_fft_options, from_cli
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/fft/parser_support.py", line 29, in <module>
from .backend_support import get_backend_modules, get_backend_names
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/fft/backend_support.py", line 77, in <module>
mod = __import__('pycbc.fft.backend_' + scheme_name, fromlist = ['_alist', '_adict'])
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/fft/backend_cpu.py", line 18, in <module>
from .core import _list_available
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/fft/core.py", line 29, in <module>
from pycbc.types import Array as _Array
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/types/__init__.py", line 1, in <module>
from .array import *
File "/home/gopi/py3/lib/python3.6/site-packages/pycbc/types/array.py", line 32, in <module>
import h5py
File "/home/gopi/py3/lib/python3.6/site-packages/h5py/__init__.py", line 46, in <module>
from ._conv import register_converters as _register_converters
File "h5py/h5t.pxd", line 14, in init h5py._conv
File "h5py/numpy.pxd", line 66, in init h5py.h5t
AttributeError: module 'numpy' has no attribute 'dtype'
Also I cannot import numpy or PyCBC at Python shell opened at Desktop. The main use of this virtualenv is to run PyCBC codes using Python3.
It's because environments' root located at the directory you create it, so it's blind to directories that are of a higher hierarchy than it (e.g., if your home dir path is C:\Username\Home and you create a virtual environment in it - it won't be able to see files in C:\Username dir), that's one of the reasons you create a virtual environment in the first place, so that it won't conflict with files in other directories.
So to fix it you basically have two options:
Create an environment in the top-heirarchy directory of your files you plan to use.
Move your files to a directory that your current environments' root dir is a root of.
Cheers.

When I try to run Python script on any editor or cmd I get this error

on editor Sublime Text 3, visual studio code, notepad++ or cmd the same problem
C:\Users\Egypt>python Desktop/python/any file.py
when i try run any file i get this
Traceback (most recent call last):
File "Desktop/python/reqweb.py", line 1, in <module>
from selenium import webdriver
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 28, in <module>
import shutil
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 22, in <module>
import bz2
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\bz2.py", line 18, in <module>
from threading import RLock
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\tokenize.py", line 34, in <module>
from token import *
File "C:\Users\Egypt\Desktop\python\token.py", line 1, in <module>
import facebook
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\facebook\__init__.py", line 30, in <module>
import requests
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\__init__.py", line 43, in <module>
import urllib3
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 3, in <module>
import logging
File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\logging\__init__.py", line 207, in <module>
_lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'
please help i try uninstall python and reinstall But the same problem
this error Appears only in scripts inside import models
I realize the comment above more or less resolved the issue, but to explain what was actually happening (because I just had a very similar problem and found this question):
It looks like your file C:\Users\Egypt\Desktop\python\token.py was incorrectly being picked as the source for the from token import * statement in the system's C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\tokenize.py module. It was actually intending to reference the module C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\token.py. Since your version of the file wasn't what it expected, it raised an exception.
Either of these fixes should work in this case:
Rename your token.py file to a non-conflicting name
Don't execute python from this folder as the current directory.

After conda update --all, Qt breaks in iPython

I ran "conda update --all" and it updated a lot of things, including Python itself (from 3.5.2-0 to 3.5.3-1, I think) and PyQt. I have used Pip in the past; I imagine they might conflict. Now when I try to run an iPython session, as soon as I evaluate a plot, the kernel dies, and I get a lot of "ImportError: No module named 'PyQt4.QtGui'" errors.
I opened a Python shell and found that QtGui exists in PyQt5 but not PyQt4:
>>> import PyQt4
>>> import PyQt4.QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtGui'
>>> import PyQt5
>>> import PyQt5.QtGui
I run Linux, specifically Ubuntu 16.04.
What should I do?
Here's the full traceback:
Traceback (most recent call last):
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/ultratb.py", line 116, in <module>
from IPython.core import debugger
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/debugger.py", line 46, in <module>
from pdb import Pdb as OldPdb
File "/home/jeff/apps/pythoon-libs/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/home/jeff/stats_with_luis/code.py", line 1, in <module>
import pandas
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/__init__.py", line 58, in <module>
from pandas.io.api import *
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/api.py", line 8, in <module>
from pandas.io.clipboard.clipboard import read_clipboard
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/__init__.py", line 103, in <module>
copy, paste = determine_clipboard()
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/__init__.py", line 76, in determine_clipboard
return init_qt_clipboard()
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/clipboards.py", line 49, in init_qt_clipboard
from PyQt4.QtGui import QApplication
ImportError: No module named 'PyQt4.QtGui'

Resources