I have a little problem in using Spyder to run a python program:
This is my program:
from PySide.QtGui import QApplication
from pyoppinet.helper.correlation_manager import *
import pyoppinet.network as nt
import numpy as np
from pyoppinet.node import node
from pyoppinet.GUI import network_view as nw
from pyoppinet.pipe.flowline import Flowline
network = nt.PipeLineNetwork(1000.2000)
source1 = node.Source(10,200)
source1.name = 'source1'
source2 = node.Source(150,500)
source2.name = 'source2'
source3 = node.Source(200,400)
source3.name = 'source3'
junction1 =node.Junction(150,600)
junction1.name = 'junction'
sink =node.Sink(300,800)
sink.name = 'sink'
for n in [source1,source2,source3,junction1,sink]:
network.add_node(n)
fl1=Flowline(source1,junction1)
fl2=Flowline(junction1,sink)
fl3=Flowline(source2,sink)
fl4=Flowline(source2,junction1)
fl5=Flowline(source3,sink)
fl6=Flowline(source3,junction1)
for n in [fl1,fl2,fl3,fl4,fl5,fl6]:
network.add_flowline(n)
print [n.name for n in network.get_nodes()]
print 'topological sort', [n.name for n in network.topological_sort()]
a=QApplication([])
view=nw.PipeLineNetworkView(network)
view.show()
a.exec_()
These two rows:
from pyoppinet.helper.correlation_manager import *
import numpy as np
are error.
And the error is:
Traceback (most recent call last):
File "D:\program oppinet\latihan\latihan.py", line 9, in <module>
from pyoppinet.helper.correlation_manager import *
File "D:\program oppinet\pyoppinet\__init__.py", line 1, in <module>
import GUI
File "D:\program oppinet\pyoppinet\GUI\__init__.py", line 7, in <module>
"""
File "D:\program oppinet\pyoppinet\GUI\viewmodelbase.py", line 1, in <module>
File "D:\program oppinet\pyoppinet\GUI\framework\__init__.py", line 3, in <module>
# Copyright © 2011 Pierre Raybaut
File "D:\program oppinet\pyoppinet\GUI\framework\GUI_helper.py", line 1, in <module>
File "D:\program oppinet\pyoppinet\helper\__init__.py", line 3, in <module>
# Copyright © 2011 Pierre Raybaut
File "D:\program oppinet\pyoppinet\helper\UnitInfo.py", line 2, in <module>
File "D:\program oppinet\pyoppinet\C_API\converter.py", line 26, in <module>
File "D:\program oppinet\pyoppinet\C_API\converter.py", line 18, inswig_import_helper
ImportError: No module named _converter
I believe that the error is caused by the setting in spyder, maybe in tools or something.
Could I change some setting in spyder to fix this problem?
Related
import pandas as pd
import os
import time
from datetime import datetime
path = "/Users/tommasomasaracchio/Documents/pythonfolder"
def key_stats(gather="Total Deb/Equity (mrg)"):
statspath = path + '/KeyStats'
stock_list = [x[0] for x in os.walk(statspath)]
print(stock_list)
key_stats()
I thought the problem was gather but it seems not to be the case.
the terminal tells me this, and I don't really understand it
tommaso desktop % python programma.py
hello world
Traceback (most recent call last):
File "/Users/tommasomasaracchio/Desktop/programma.py", line 2, in <module>
import pandas as pd
File "/Users/tommasomasaracchio/opt/anaconda3/lib/python3.9/site-packages/pandas/__init__.py", line 179, in <module>
import pandas.testing
File "/Users/tommasomasaracchio/opt/anaconda3/lib/python3.9/site-packages/pandas/testing.py", line 6, in <module>
from pandas._testing import (
File "/Users/tommasomasaracchio/opt/anaconda3/lib/python3.9/site-packages/pandas/_testing/__init__.py", line 58, in <module>
from pandas._testing._io import ( # noqa:F401
File "/Users/tommasomasaracchio/opt/anaconda3/lib/python3.9/site-packages/pandas/_testing/_io.py", line 22, in <module>
from pandas._testing._random import rands
File "/Users/tommasomasaracchio/opt/anaconda3/lib/python3.9/site-packages/pandas/_testing/_random.py", line 10, in <module>
RANDS_CHARS = np.array(list(string.ascii_letters + string.digits), dtype=(np.str_, 1))
AttributeError: module 'string' has no attribute 'ascii_letters'
I am trying to make a map in python using shapefiles I have downloaded from bbike.org. Here is my code:
import geopandas as gpd
import os
import sys
import matplotlib.pyplot as plt
bos_files_list = ['buildings.shx', 'landuse.shx', 'natural.shx', 'places.shx', 'points.shx', 'railways.shx', 'roads.shx']
cur_path = os.path.dirname(__file__)
def maps_of_bos(files):
for x in range(len(files)):
os.chdir(f'location/of/file')
f = open(f'{files[x]}', 'r')
gpd.read_file(f)
z = maps_of_bos(bos_files_list)
z.plot()
plt.show()
However, my error output is as follows:
Traceback (most recent call last):
File "test.py", line 16, in <module>
z = maps_of_bos(bos_files_list)
File "test.py", line 13, in maps_of_bos
gpd.read_file(f)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/geopandas/io/f
ile.py", line 76, in read_file
with reader(path_or_bytes, **kwargs) as features:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 113, in
__enter__
return next(self.gen)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fiona/__init__
.py", line 206, in fp_reader
dataset = memfile.open()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fiona/io.py",
line 63, in open
return Collection(vsi_path, 'w', crs=crs, driver=driver,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fiona/collecti
on.py", line 126, in __init__
raise DriverError("no driver")
fiona.errors.DriverError: no driver
I am relatively new to python, and don't really understand my error. can someone please help me?
According to the docs read_file should take the path to the file not an object.
gpd.read_file(f'{files[x]}')
you dont need
f = open(f'{files[x]}', 'r')
I'm trying to use the library Chatterbot, but I got this error RuntimeError: implement_array_function method already has a docstring I don't understand! Can you help me?
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')
trainer = ListTrainer(chatbot)
trainer.train([
"Hi, can I help you?",
"Sure, I'd like to book a flight to Iceland.",
"Your flight has been booked."
])
# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')
print(response)
> "C:\Users\Juan Montañez\PycharmProjects\1\Scripts\python.exe"
> "C:/Users/Juan Montañez/ChatBot/Perseus/index.py" Traceback (most
> recent call last): File "C:/Users/Juan
> Montañez/ChatBot/Perseus/index.py", line 1, in <module>
> from chatterbot import ChatBot File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\chatterbot\__init__.py",
> line 4, in <module>
> from .chatterbot import ChatBot File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\chatterbot\chatterbot.py",
> line 2, in <module>
> from chatterbot.storage import StorageAdapter File "C:\Users\Juan
> Montañez\PycharmProjects\1\lib\site-packages\chatterbot\storage\__init__.py",
> line 1, in <module>
> from chatterbot.storage.storage_adapter import StorageAdapter File "C:\Users\Juan
> Montañez\PycharmProjects\1\lib\site-packages\chatterbot\storage\storage_adapter.py",
> line 3, in <module>
> from chatterbot.tagging import PosHypernymTagger File "C:\Users\Juan
> Montañez\PycharmProjects\1\lib\site-packages\chatterbot\tagging.py",
> line 3, in <module>
> from chatterbot import utils File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\chatterbot\utils.py",
> line 4, in <module>
> from nltk.corpus import wordnet File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\nltk\__init__.py", line
> 129, in <module>
> from nltk.collocations import * File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\nltk\collocations.py",
> line 40, in <module>
> from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures, QuadgramAssocMeasures File "C:\Users\Juan
> Montañez\PycharmProjects\1\lib\site-packages\nltk\metrics\__init__.py",
> line 16, in <module>
> from nltk.metrics.scores import ( File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\nltk\metrics\scores.py",
> line 18, in <module>
> from scipy.stats.stats import betai File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\scipy\__init__.py", line
> 62, in <module>
> from numpy import show_config as show_numpy_config File "C:\Users\Juan
> Montañez\PycharmProjects\1\lib\site-packages\numpy\__init__.py", line
> 142, in <module>
> from . import add_newdocs File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\add_newdocs.py",
> line 13, in <module>
> from numpy.lib import add_newdoc File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\lib\__init__.py",
> line 9, in <module>
> from .index_tricks import * File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\lib\index_tricks.py",
> line 13, in <module>
> import numpy.matrixlib as matrixlib File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\matrixlib\__init__.py",
> line 6, in <module>
> from .defmatrix import * File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\matrixlib\defmatrix.py",
> line 12, in <module>
> from numpy.linalg import matrix_power File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\linalg\__init__.py",
> line 51, in <module>
> from .linalg import * File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\linalg\linalg.py",
> line 32, in <module>
> from numpy.core.overrides import set_module File "C:\Users\Juan Montañez\PycharmProjects\1\lib\site-packages\numpy\core\overrides.py",
> line 46, in <module>
> """) RuntimeError: implement_array_function method already has a docstring
See numpy issue.
Try downgrading numpy to version 1.15.4.
You may get another error like typing-extensions module not found.
Simply pip install the missing module.
I am using python 2.7 and pyBarcode 0.7 in Windows and I am trying to generate barcode as png image by using following sample code (available in pyBarcode webpage)
>>> import barcode
>>> barcode.PROVIDED_BARCODES
[u'code39', u'ean', u'ean13', u'ean8', u'gs1', u'gtin', u'isbn', u'isbn10',
u'isbn13', u'issn', u'jan', u'pzn', u'upc', u'upca']
>>> EAN = barcode.get_barcode_class('ean13')
>>> EAN
<class 'barcode.ean.EuropeanArticleNumber13'>
>>> ean = EAN(u'5901234123457')
>>> ean
<barcode.ean.EuropeanArticleNumber13 object at 0x00BE98F0>
# Example with PNG
>>> from barcode.writer import ImageWriter
>>> ean = EAN(u'5901234123457', writer=ImageWriter())
>>> fullname = ean.save('ean13_barcode')
Last line generates following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python27\lib\site-packages\barcode\base.py", line 68, in save
output = self.render(options)
File "c:\python27\lib\site-packages\barcode\ean.py", line 106, in render
return Barcode.render(self, options)
File "c:\python27\lib\site-packages\barcode\base.py", line 103, in render
raw = Barcode.raw = self.writer.render(code)
File "c:\python27\lib\site-packages\barcode\writer.py", line 188, in render
self._callbacks['paint_text'](xpos, ypos)
File "c:\python27\lib\site-packages\barcode\writer.py", line 280, in _paint_te
xt
font = ImageFont.truetype(FONT, self.font_size * 2)
File "c:\python27\lib\site-packages\PIL\ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "c:\python27\lib\site-packages\PIL\ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
File "c:\python27\lib\site-packages\PIL\ImageFont.py", line 34, in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed
I retried by installing Pillow (but before that I removed PIL); I downloaded "Pillow-4.2.1-win32-py2_7.exe"
and I did also "pip install Pillow".
Now when I try to run
import barcode
I got:
File "barcode\codex.py", line 12, in <module>
from barcode.base import Barcode
File "barcode\base.py", line 9, in <module>
from barcode.writer import SVGWriter
File "barcode\writer.py", line 12, in <module>
import Image, ImageDraw, ImageFont
File "c:\python27\lib\site-packages\PIL\Image.py", line 27, in <module>
from . import VERSION, PILLOW_VERSION, _plugins
ValueError: Attempted relative import in non-package
What should I do ?
thanks
I have install shapely on my pc win 64 bit python 2.7. When i write import shapely it works fine. But the above error comes in the following code:
import numpy as np
from scipy.spatial import Voronoi, voronoi_plot_2d
import shapely.geometry
import shapely.ops
points = np.random.random((10, 2))
vor = Voronoi(points)
voronoi_plot_2d(vor)
lines = [
shapely.geometry.LineString(vor.vertices[line])
for line in vor.ridge_vertices
if -1 not in line
]
for poly in shapely.ops.polygonize(lines):
print poly
Error:
Traceback (most recent call last):
File "C:\Users\Shikha\Desktop\vorn.py", line 3, in <module>
import shapely.geometry
File "C:\Python27\lib\site-packages\shapely-1.5.9-py2.7.egg\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Python27\lib\site-packages\shapely-1.5.9-py2.7.egg\shapely\geometry\base.py", line 9, in <module>
from shapely.coords import CoordinateSequence
File "C:\Python27\lib\site-packages\shapely-1.5.9-py2.7.egg\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Python27\lib\site-packages\shapely-1.5.9-py2.7.egg\shapely\geos.py", line 145, in <module>
prototype(_lgeos, geos_version)
File "C:\Python27\lib\site-packages\shapely-1.5.9-py2.7.egg\shapely\ctypes_declarations.py", line 252, in prototype
lgeos.GEOSCovers.restype = c_byte
File "C:\Python27\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Python27\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'GEOSCovers' not found